4 <script src=
"../../resources/js-test.js"></script>
7 <canvas id=
"mycanvas" width=
"200" height=
"200"></canvas>
10 if (window
.testRunner
) {
11 testRunner
.dumpAsText();
12 testRunner
.waitUntilDone();
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);
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();