OLD | NEW |
1 <!DOCTYPE html> | 1 <script src="../../resources/testharness.js"></script> |
2 <html> | 2 <script src="../../resources/testharnessreport.js"></script> |
3 <head> | |
4 <script src="../../resources/js-test.js"></script> | |
5 </head> | |
6 <body> | 3 <body> |
7 <canvas id="destination" width="300" height="300"></canvas> | 4 <canvas id="destination" width="300" height="300"></canvas> |
8 <canvas id="source" width="300" height="300"></canvas> | 5 <canvas id="source" width="300" height="300"></canvas> |
9 <script src="script-tests/canvas-imageSmoothingEnabled-repaint.js"></script> | 6 <script> |
| 7 // This is a regression test for bug https://bugs.webkit.org/show_bug.cgi?id=890
18 |
| 8 var dstCanvas = document.getElementById("destination"); |
| 9 var dstCtx = dstCanvas.getContext('2d'); |
| 10 var srcCanvas = document.getElementById("source"); |
| 11 var srcCtx = srcCanvas.getContext('2d'); |
| 12 |
| 13 var srcCanvas, srcCtx, dstCanvas, dstCtx; |
| 14 |
| 15 function draw() |
| 16 { |
| 17 srcCtx.clearRect(0, 0, 300, 300); |
| 18 dstCtx.clearRect(0, 0, 300, 300); |
| 19 srcCtx.fillStyle = "rgb(255, 0, 0)"; |
| 20 srcCtx.fillRect(0, 0, 1, 1); |
| 21 srcCtx.fillStyle = "rgb(0, 255, 0)"; |
| 22 srcCtx.fillRect(1, 0, 1, 1); |
| 23 dstCtx.imageSmoothingEnabled = false; |
| 24 dstCtx.drawImage(srcCanvas, 0, 0, 2, 1, 0, 0, 300, 300); |
| 25 } |
| 26 |
| 27 // Bug 89018 requires 2 draw iteration in order to manifest itself. |
| 28 var drawIterations = 2; |
| 29 |
| 30 function BrowserPaint() |
| 31 { |
| 32 draw(); |
| 33 if (drawIterations > 0) { |
| 34 drawIterations = drawIterations - 1; |
| 35 window.requestAnimationFrame(BrowserPaint); |
| 36 return; |
| 37 } |
| 38 test(function(t) { |
| 39 // Test that the image is not filtered |
| 40 left_of_center_pixel = dstCtx.getImageData(149, 150, 1, 1); |
| 41 assert_equals(left_of_center_pixel.data[0], 255); |
| 42 assert_equals(left_of_center_pixel.data[1], 0); |
| 43 assert_equals(left_of_center_pixel.data[2], 0); |
| 44 right_of_center_pixel = dstCtx.getImageData(150, 150, 1, 1); |
| 45 assert_equals(right_of_center_pixel.data[0], 0); |
| 46 assert_equals(right_of_center_pixel.data[1], 255); |
| 47 assert_equals(right_of_center_pixel.data[2], 0); |
| 48 }, "Tests that disabling the imageSmoothingEnabled attribute still works aft
er multiple repaints"); |
| 49 } |
| 50 |
| 51 window.onload = BrowserPaint; |
| 52 |
| 53 </script> |
10 </body> | 54 </body> |
11 </html> | |
OLD | NEW |