| OLD | NEW |
| 1 <!-- Based on fast/repaint/canvas-putImageData.html --> | 1 <!-- Based on fast/repaint/canvas-putImageData.html --> |
| 2 <!-- Test for https://bugs.webkit.org/show_bug.cgi?id=46319 --> | 2 <!-- Test for https://bugs.webkit.org/show_bug.cgi?id=46319 --> |
| 3 <head> | 3 <head> |
| 4 <script src="resources/paint-invalidation-test.js"></script> | 4 <script src="resources/paint-invalidation-test.js"></script> |
| 5 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <canvas id="canvas" width="100" height="100"></canvas> | 7 <canvas id="canvas" width="100" height="100"></canvas> |
| 8 <script> | 8 <script> |
| 9 var canvas = document.getElementById('canvas'); | 9 var canvas = document.getElementById('canvas'); |
| 10 var ctx = canvas.getContext('2d'); | 10 var ctx = canvas.getContext('2d'); |
| 11 | 11 |
| 12 // prepare imagedata | 12 // prepare imagedata |
| 13 ctx.fillStyle = "rgb(255, 0, 0)"; ctx.fillRect(0, 0, 100, 100); // red b
ackground | 13 ctx.fillStyle = "rgb(255, 0, 0)"; ctx.fillRect(0, 0, 100, 100); // red b
ackground |
| 14 ctx.fillStyle = "rgb(0, 255, 0)"; ctx.fillRect(10, 10, 10, 10); // inset
green square | 14 ctx.fillStyle = "rgb(0, 255, 0)"; ctx.fillRect(10, 10, 10, 10); // inset
green square |
| 15 var imageDataGreen = ctx.getImageData(10, 10, 10, 10); | 15 var imageDataGreen = ctx.getImageData(10, 10, 10, 10); |
| 16 var imageDataRedWithInsetGreen = ctx.getImageData(0, 0, 30, 30); | 16 var imageDataRedWithInsetGreen = ctx.getImageData(0, 0, 30, 30); |
| 17 | 17 |
| 18 // clear canvas to dark green | 18 // clear canvas to dark green |
| 19 ctx.fillStyle = "rgb(0, 128, 0)"; | 19 ctx.fillStyle = "rgb(0, 128, 0)"; |
| 20 ctx.fillRect(0, 0, 100, 100); | 20 ctx.fillRect(0, 0, 100, 100); |
| 21 | 21 |
| 22 // fill target locations with dark red | 22 // fill target locations with dark red |
| 23 ctx.fillStyle = "rgb(128, 0, 0)"; | 23 ctx.fillStyle = "rgb(128, 0, 0)"; |
| 24 ctx.fillRect(0, 0, 10, 10); | 24 ctx.fillRect(0, 0, 10, 10); |
| 25 ctx.fillRect(40, 40, 10, 10); | 25 ctx.fillRect(40, 40, 10, 10); |
| 26 ctx.fillRect(80, 80, 10, 10); | 26 ctx.fillRect(80, 80, 10, 10); |
| 27 window.testIsAsync = true; | 27 window.testIsAsync = true; |
| 28 | 28 |
| 29 window.expectedPaintInvalidationObjects = [ | |
| 30 "LayoutHTMLCanvas CANVAS id='canvas'", | |
| 31 ]; | |
| 32 function paintInvalidationTest() | 29 function paintInvalidationTest() |
| 33 { | 30 { |
| 34 // patch up red squares with putImageData | 31 // patch up red squares with putImageData |
| 35 ctx.putImageData(imageDataGreen, 0, 0); | 32 ctx.putImageData(imageDataGreen, 0, 0); |
| 36 ctx.putImageData(imageDataGreen, 40, 40); | 33 ctx.putImageData(imageDataGreen, 40, 40); |
| 37 ctx.putImageData(imageDataRedWithInsetGreen, 70, 70, 10, 10, 10, 10)
; | 34 ctx.putImageData(imageDataRedWithInsetGreen, 70, 70, 10, 10, 10, 10)
; |
| 38 // Because canvas invalidations are processed at the end of the curr
ent task, | 35 // Because canvas invalidations are processed at the end of the curr
ent task, |
| 39 // the repaint test has to end in a subsequent task in order to capt
ure the repaint. | 36 // the repaint test has to end in a subsequent task in order to capt
ure the repaint. |
| 40 setTimeout(finishPaintInvalidationTest, 0); | 37 setTimeout(finishPaintInvalidationTest, 0); |
| 41 } | 38 } |
| 42 | 39 |
| 43 window.onload = runPaintInvalidationTest; | 40 window.onload = runPaintInvalidationTest; |
| 44 </script> | 41 </script> |
| 45 </body> | 42 </body> |
| OLD | NEW |