| <script src="../resources/js-test-pre.js"></script> |
| <p>The second and third results should be the same.</p> |
| const log = console.log.bind(console); |
| const canvas = document.querySelector("canvas"); |
| const ctx = canvas.getContext("2d"); |
| ctx.setLineDash([1, 2, 3]); |
| log("Using an array: " + ctx.getLineDash()); |
| const iterator = generator(); |
| ctx.setLineDash(iterator); |
| let a = ctx.getLineDash(); |
| log("Using an iterator: " + a); |
| Object.defineProperty(array, Symbol.iterator, { |
| let b = ctx.getLineDash(); |
| log("Using an array but with customized iteration (should be same as iterator): " + b); |
| if (a.toString() !== b.toString()) |
| throw new Error("Bad result. They should be equal."); |
| <script src="../resources/js-test-post.js"></script> |