d56ad6d8c34201ce9b192678193cdcfa5bac2219
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / repaint / canvas-putImageData.html
1 <!-- Test for https://bugs.webkit.org/show_bug.cgi?id=46319 -->
2 <head>
3     <script src="resources/text-based-repaint.js"></script>
4 </head>
5 <body>
6     <canvas id="canvas" width="100" height="100"></canvas> 
7     <script>
8         var canvas = document.getElementById('canvas');
9         var ctx = canvas.getContext('2d');
10
11         // prepare imagedata
12         ctx.fillStyle = "rgb(255, 0, 0)"; ctx.fillRect(0, 0, 100, 100); // red background
13         ctx.fillStyle = "rgb(0, 255, 0)"; ctx.fillRect(10, 10, 10, 10); // inset green square
14         var imageDataGreen = ctx.getImageData(10, 10, 10, 10);
15         var imageDataRedWithInsetGreen = ctx.getImageData(0, 0, 30, 30);
16
17         // clear canvas to dark green 
18         ctx.fillStyle = "rgb(0, 128, 0)";
19         ctx.fillRect(0, 0, 100, 100);
20
21         // fill target locations with dark red
22         ctx.fillStyle = "rgb(128, 0, 0)";
23         ctx.fillRect(0, 0, 10, 10);
24         ctx.fillRect(40, 40, 10, 10);
25         ctx.fillRect(80, 80, 10, 10);
26         
27         function repaintTest()
28         {
29             // patch up red squares with putImageData
30             ctx.putImageData(imageDataGreen, 0, 0);
31             ctx.putImageData(imageDataGreen, 40, 40);
32             ctx.putImageData(imageDataRedWithInsetGreen, 70, 70, 10, 10, 10, 10);
33         }
34
35         window.onload = runRepaintTest;
36     </script>
37 </body>