1 // This is a regression test for bug https://bugs.webkit.org/show_bug.cgi?id=89018
3 description("Tests that disabling the imageSmoothingEnabled attribute still works 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');
10 var srcCanvas, srcCtx, dstCanvas, dstCtx;
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);
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");
37 // Bug 89018 requires 2 draw iteration in order to manifest itself.
38 var drawIterations = 2;
40 function BrowserPaint(){
42 if (drawIterations > 0) {
43 drawIterations = drawIterations - 1;
44 window.requestAnimationFrame(BrowserPaint);
50 function onLoadHandler()
55 window.jsTestIsAsync = true;
56 window.onload = onLoadHandler;