| OLD | NEW |
| (Empty) |
| 1 description("Test that the rendering context's lineWidth is intact after calling
strokeRect()"); | |
| 2 var ctx = document.createElement('canvas').getContext('2d'); | |
| 3 | |
| 4 ctx.fillStyle = 'red'; | |
| 5 ctx.fillRect(0, 0, 1, 1); | |
| 6 | |
| 7 var imageData = ctx.getImageData(0, 0, 2, 1); | |
| 8 var imgdata = imageData.data; | |
| 9 shouldBe("ctx.fillStyle", "'#ff0000'"); | |
| 10 shouldBe("imgdata[0]", "255"); | |
| 11 shouldBe("imgdata[1]", "0"); | |
| 12 shouldBe("imgdata[2]", "0"); | |
| 13 shouldBe("imgdata[3]", "255"); | |
| 14 shouldBe("imgdata[4]", "0"); | |
| 15 shouldBe("imgdata[5]", "0"); | |
| 16 shouldBe("imgdata[6]", "0"); | |
| 17 shouldBe("imgdata[7]", "0"); | |
| 18 | |
| 19 ctx.strokeStyle = 'red'; | |
| 20 ctx.lineWidth = 100; | |
| 21 // NOTE: This version of strokeRect() is WebKit-specific and not part of the sta
ndard API. | |
| 22 ctx.strokeRect(0, 0, 10, 10, 1); | |
| 23 shouldBe("ctx.lineWidth", "100"); | |
| 24 | |
| 25 ctx.strokeStyle = 'green'; | |
| 26 ctx.beginPath(); | |
| 27 ctx.moveTo(0, 0); | |
| 28 ctx.lineTo(20, 20); | |
| 29 ctx.stroke(); | |
| 30 | |
| 31 imageData = ctx.getImageData(2, 2, 1, 1); | |
| 32 imgdata = imageData.data; | |
| 33 shouldBe("imgdata[0]", "0"); | |
| 34 shouldBe("imgdata[1]", "128"); | |
| 35 shouldBe("imgdata[2]", "0"); | |
| 36 shouldBe("imgdata[3]", "255"); | |
| 37 | |
| 38 document.body.appendChild(ctx.canvas) | |
| OLD | NEW |