OLD | NEW |
| (Empty) |
1 // This is a regression test for bug https://bugs.webkit.org/show_bug.cgi?id=890
18 | |
2 | |
3 description("Tests that disabling the imageSmoothingEnabled attribute still work
s after multiple repaints"); | |
4 var dstCanvas = document.getElementById("destination"); | |
5 var dstCtx = dstCanvas.getContext('2d'); | |
6 var srcCanvas = document.getElementById("source"); | |
7 var srcCtx = srcCanvas.getContext('2d'); | |
8 | |
9 | |
10 var srcCanvas, srcCtx, dstCanvas, dstCtx; | |
11 | |
12 function draw() | |
13 { | |
14 srcCtx.clearRect(0, 0, 300, 300); | |
15 dstCtx.clearRect(0, 0, 300, 300); | |
16 srcCtx.fillStyle = "rgb(255, 0, 0)"; | |
17 srcCtx.fillRect(0, 0, 1, 1); | |
18 srcCtx.fillStyle = "rgb(0, 255, 0)"; | |
19 srcCtx.fillRect(1, 0, 1, 1); | |
20 dstCtx.imageSmoothingEnabled = false; | |
21 dstCtx.drawImage(srcCanvas, 0, 0, 2, 1, 0, 0, 300, 300); | |
22 } | |
23 | |
24 function testResult() { | |
25 debug("Test that the image is not filtered"); | |
26 left_of_center_pixel = dstCtx.getImageData(149, 150, 1, 1); | |
27 shouldBe("left_of_center_pixel.data[0]", "255"); | |
28 shouldBe("left_of_center_pixel.data[1]", "0"); | |
29 shouldBe("left_of_center_pixel.data[2]", "0"); | |
30 right_of_center_pixel = dstCtx.getImageData(150, 150, 1, 1); | |
31 shouldBe("right_of_center_pixel.data[0]", "0"); | |
32 shouldBe("right_of_center_pixel.data[1]", "255"); | |
33 shouldBe("right_of_center_pixel.data[2]", "0"); | |
34 finishJSTest(); | |
35 } | |
36 | |
37 // Bug 89018 requires 2 draw iteration in order to manifest itself. | |
38 var drawIterations = 2; | |
39 | |
40 function BrowserPaint(){ | |
41 draw(); | |
42 if (drawIterations > 0) { | |
43 drawIterations = drawIterations - 1; | |
44 window.requestAnimationFrame(BrowserPaint); | |
45 } else { | |
46 testResult(); | |
47 } | |
48 } | |
49 | |
50 function onLoadHandler() | |
51 { | |
52 BrowserPaint(); | |
53 } | |
54 | |
55 window.jsTestIsAsync = true; | |
56 window.onload = onLoadHandler; | |
57 | |
OLD | NEW |