| OLD | NEW |
| (Empty) |
| 1 description("Test that the rendering context's strokeStyle and fillStyle are int
act after calling strokeText() and fillText()"); | |
| 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 fillText() to try and break the strokeStyle."); | |
| 21 ctx.strokeStyle = 'green'; | |
| 22 ctx.lineWidth = 10; | |
| 23 ctx.fillStyle = 'red'; | |
| 24 ctx.fillText("X", 0, 0); | |
| 25 shouldBe("ctx.strokeStyle", "'#008000'"); | |
| 26 ctx.beginPath(); | |
| 27 ctx.moveTo(0, 0); | |
| 28 ctx.lineTo(10, 10); | |
| 29 ctx.stroke(); | |
| 30 imageData = ctx.getImageData(2, 2, 1, 1); | |
| 31 imgdata = imageData.data; | |
| 32 shouldBe("imgdata[0]", "0"); | |
| 33 shouldBe("imgdata[1]", "128"); | |
| 34 shouldBe("imgdata[2]", "0"); | |
| 35 shouldBe("imgdata[3]", "255"); | |
| 36 | |
| 37 debug("Calling strokeText() to try and break the fillStyle."); | |
| 38 ctx.strokeStyle = 'red'; | |
| 39 ctx.lineWidth = 100; | |
| 40 ctx.fillStyle = 'green'; | |
| 41 ctx.strokeText("X", 0, 0); | |
| 42 shouldBe("ctx.fillStyle", "'#008000'"); | |
| 43 ctx.fillRect(0, 0, 10, 10); | |
| 44 imageData = ctx.getImageData(2, 2, 1, 1); | |
| 45 imgdata = imageData.data; | |
| 46 shouldBe("imgdata[0]", "0"); | |
| 47 shouldBe("imgdata[1]", "128"); | |
| 48 shouldBe("imgdata[2]", "0"); | |
| 49 shouldBe("imgdata[3]", "255"); | |
| OLD | NEW |