| OLD | NEW |
| (Empty) |
| 1 description("Test the handling of negative sourceRect offset in getImageData()."
); | |
| 2 | |
| 3 ctx = document.createElement('canvas').getContext('2d'); | |
| 4 | |
| 5 ctx.fillStyle = 'red'; | |
| 6 ctx.fillRect(0, 0, 100, 100); | |
| 7 ctx.fillStyle = 'green'; | |
| 8 ctx.fillRect(0, 0, 6, 6); | |
| 9 | |
| 10 var imageData = ctx.getImageData(-10, 0, 100, 1); | |
| 11 var imgdata = imageData.data; | |
| 12 | |
| 13 // Fully transparent black | |
| 14 shouldBe("imgdata[0]", "0"); | |
| 15 shouldBe("imgdata[1]", "0"); | |
| 16 shouldBe("imgdata[2]", "0"); | |
| 17 shouldBe("imgdata[3]", "0"); | |
| 18 | |
| 19 // Green | |
| 20 shouldBe("imgdata[60]", "0"); | |
| 21 shouldBe("imgdata[61]", "128"); | |
| 22 shouldBe("imgdata[62]", "0"); | |
| 23 shouldBe("imgdata[63]", "255"); | |
| 24 | |
| 25 // Red | |
| 26 shouldBe("imgdata[64]", "255"); | |
| 27 shouldBe("imgdata[65]", "0"); | |
| 28 shouldBe("imgdata[66]", "0"); | |
| 29 shouldBe("imgdata[67]", "255"); | |
| OLD | NEW |