OLD | NEW |
1 description("Tests for the imageSmoothingEnabled attribute."); | 1 description("Tests for the imageSmoothingEnabled attribute."); |
2 var ctx = document.createElement('canvas').getContext('2d'); | 2 var ctx = document.createElement('canvas').getContext('2d'); |
3 | 3 |
4 debug("Test that the default value is true."); | 4 debug("Test that the default value is true."); |
5 shouldBe("ctx.imageSmoothingEnabled", "true"); | 5 shouldBe("ctx.imageSmoothingEnabled", "true"); |
6 shouldBe("ctx.webkitImageSmoothingEnabled", "true"); | |
7 | 6 |
8 debug("Test that false is returned after a the attribute is set to false."); | 7 debug("Test that false is returned after a the attribute is set to false."); |
9 ctx.imageSmoothingEnabled = false; | 8 ctx.imageSmoothingEnabled = false; |
10 shouldBe("ctx.imageSmoothingEnabled", "false"); | 9 shouldBe("ctx.imageSmoothingEnabled", "false"); |
11 shouldBe("ctx.webkitImageSmoothingEnabled", "false"); | |
12 | 10 |
13 debug("Test that restore works. We save a false state; create, then save a true
state; and then finally restore."); | 11 debug("Test that restore works. We save a false state; create, then save a true
state; and then finally restore."); |
14 ctx.save(); | 12 ctx.save(); |
15 ctx.imageSmoothingEnabled = true; | 13 ctx.imageSmoothingEnabled = true; |
16 ctx.restore(); | 14 ctx.restore(); |
17 shouldBe("ctx.imageSmoothingEnabled", "false"); | 15 shouldBe("ctx.imageSmoothingEnabled", "false"); |
18 | 16 |
19 var image = document.createElement('canvas'); | 17 var image = document.createElement('canvas'); |
20 image.width = 2; | 18 image.width = 2; |
21 image.height = 1; | 19 image.height = 1; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 ctx.imageSmoothingEnabled = false; | 69 ctx.imageSmoothingEnabled = false; |
72 ctx.save(); | 70 ctx.save(); |
73 ctx.imageSmoothingEnabled = true; | 71 ctx.imageSmoothingEnabled = true; |
74 ctx.restore(); | 72 ctx.restore(); |
75 ctx.drawImage(image, 0, 0, canvas.width, canvas.height); | 73 ctx.drawImage(image, 0, 0, canvas.width, canvas.height); |
76 left_of_center_pixel = ctx.getImageData(1, 0, 1, 1); | 74 left_of_center_pixel = ctx.getImageData(1, 0, 1, 1); |
77 shouldBe("left_of_center_pixel.data[0]", "0"); | 75 shouldBe("left_of_center_pixel.data[0]", "0"); |
78 shouldBe("left_of_center_pixel.data[1]", "0"); | 76 shouldBe("left_of_center_pixel.data[1]", "0"); |
79 shouldBe("left_of_center_pixel.data[2]", "0"); | 77 shouldBe("left_of_center_pixel.data[2]", "0"); |
80 | 78 |
OLD | NEW |