| OLD | NEW |
| (Empty) |
| 1 description("Series of tests to ensure correct behavior of canvas.clearRect().")
; | |
| 2 var ctx = document.createElement('canvas').getContext('2d'); | |
| 3 | |
| 4 // Clear rect with height = width = 0. | |
| 5 debug("Test canvas.clearRect() with height = width = 0."); | |
| 6 ctx.fillStyle = 'red'; | |
| 7 ctx.fillRect(0, 0, 1, 1); | |
| 8 ctx.clearRect(0, 0, 0, 0); | |
| 9 | |
| 10 var imageData = ctx.getImageData(0, 0, 1, 1); | |
| 11 var imgdata = imageData.data; | |
| 12 shouldBe("imgdata[0]", "255"); | |
| 13 shouldBe("imgdata[1]", "0"); | |
| 14 shouldBe("imgdata[2]", "0"); | |
| 15 | |
| 16 ctx.clearRect(0, 0, 1, 1); | |
| 17 | |
| 18 // Clear rect with height = 0, width = 1. | |
| 19 debug("Test canvas.clearRect() with height = 0, width = 1."); | |
| 20 ctx.fillStyle = 'red'; | |
| 21 ctx.fillRect(0, 0, 1, 1); | |
| 22 ctx.clearRect(0, 0, 1, 0); | |
| 23 | |
| 24 var imageData = ctx.getImageData(0, 0, 1, 1); | |
| 25 var imgdata = imageData.data; | |
| 26 shouldBe("imgdata[0]", "255"); | |
| 27 shouldBe("imgdata[1]", "0"); | |
| 28 shouldBe("imgdata[2]", "0"); | |
| 29 | |
| 30 ctx.clearRect(0, 0, 1, 1); | |
| 31 | |
| 32 // Clear rect with height = 1, width = 0. | |
| 33 debug("Test canvas.clearRect() with height = 1, width = 0."); | |
| 34 ctx.fillStyle = 'red'; | |
| 35 ctx.fillRect(0, 0, 1, 1); | |
| 36 ctx.clearRect(0, 0, 0, 1); | |
| 37 | |
| 38 var imageData = ctx.getImageData(0, 0, 1, 1); | |
| 39 var imgdata = imageData.data; | |
| 40 shouldBe("imgdata[0]", "255"); | |
| 41 shouldBe("imgdata[1]", "0"); | |
| 42 shouldBe("imgdata[2]", "0"); | |
| 43 | |
| 44 ctx.clearRect(0, 0, 1, 1); | |
| OLD | NEW |