| OLD | NEW |
| (Empty) |
| 1 description("Test that the rendering context state is intact after a call to put
ImageData()"); | |
| 2 var ctx = document.createElement('canvas').getContext('2d'); | |
| 3 | |
| 4 ctx.fillStyle = 'red'; | |
| 5 ctx.fillRect(0, 0, 1, 1); | |
| 6 | |
| 7 debug("Checking initial state for sanity"); | |
| 8 var imageData = ctx.getImageData(0, 0, 2, 1); | |
| 9 var imgdata = imageData.data; | |
| 10 shouldBe("ctx.fillStyle", "'#ff0000'"); | |
| 11 shouldBe("imgdata[0]", "255"); | |
| 12 shouldBe("imgdata[1]", "0"); | |
| 13 shouldBe("imgdata[2]", "0"); | |
| 14 shouldBe("imgdata[3]", "255"); | |
| 15 shouldBe("imgdata[4]", "0"); | |
| 16 shouldBe("imgdata[5]", "0"); | |
| 17 shouldBe("imgdata[6]", "0"); | |
| 18 shouldBe("imgdata[7]", "0"); | |
| 19 | |
| 20 debug("Calling putImageData()"); | |
| 21 ctx.putImageData(imageData, 1, 1); | |
| 22 imageData = ctx.getImageData(1, 1, 1, 1); | |
| 23 imgdata = imageData.data; | |
| 24 shouldBe("imgdata[0]", "255"); | |
| 25 shouldBe("imgdata[1]", "0"); | |
| 26 shouldBe("imgdata[2]", "0"); | |
| 27 shouldBe("imgdata[3]", "255"); | |
| 28 | |
| 29 debug("Checking if state is intact"); | |
| 30 shouldBe("ctx.fillStyle", "'#ff0000'"); | |
| 31 | |
| 32 ctx.fillRect(2, 2, 1, 1); | |
| 33 imageData = ctx.getImageData(2, 2, 1, 1); | |
| 34 imgdata = imageData.data; | |
| 35 shouldBe("imgdata[0]", "255"); | |
| 36 shouldBe("imgdata[1]", "0"); | |
| 37 shouldBe("imgdata[2]", "0"); | |
| 38 shouldBe("imgdata[3]", "255"); | |
| OLD | NEW |