Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / canvas / canvas-after-detachment.html
blobe304ca25fe5be347d0b40e432c7c0fb8318e0dd2
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <div id="parent">
7 <canvas id="mycanvas" width="200" height="200"></canvas>
8 </div>
9 <script>
10 if (window.testRunner) {
11 testRunner.dumpAsText();
12 testRunner.waitUntilDone();
15 var data;
16 function runTest()
18 var parent = document.getElementById("parent");
19 var canvas = document.getElementById('mycanvas');
20 var ctx = canvas.getContext('2d');
21 ctx.fillStyle = 'red';
22 ctx.fillRect(0, 0, 200, 200);
24 var imageData;
25 imageData = ctx.getImageData(100, 100, 1, 1);
26 data = imageData.data;
27 shouldBe('data[0]', '255');
28 shouldBe('data[1]', '0');
29 shouldBe('data[2]', '0');
31 parent.removeChild(canvas);
32 // GC makes sure canvas element is removed.
33 if (window.GCController)
34 GCController.collect();
36 imageData = ctx.getImageData(100, 100, 1, 1);
37 data = imageData.data;
38 // The context is valid although the canvas is detached from document.
39 shouldBe('data[0]', '255');
40 shouldBe('data[1]', '0');
41 shouldBe('data[2]', '0');
43 if (window.testRunner)
44 testRunner.notifyDone();
47 runTest();
48 </script>
49 </body>
50 </html>