4 <script src=
"../../resources/js-test.js"></script>
8 if (window
.testRunner
) {
9 testRunner
.dumpAsText();
10 testRunner
.waitUntilDone();
14 function frameLoaded()
23 debug("check if re-parenting canvas keeps its context.")
24 canvasTest(document
.getElementById("frame1"), true);
25 debug("check if detaching canvas loses its context.")
26 canvasTest(document
.getElementById("frame2"), false);
28 if (window
.testRunner
)
29 testRunner
.notifyDone();
33 function canvasTest(frame
, adoptCanvas
)
35 var parent
= document
.getElementById("parent");
36 var canvas
= frame
.contentDocument
.getElementById('mycanvas');
37 var ctx
= canvas
.getContext('2d');
40 imageData
= ctx
.getImageData(100, 100, 1, 1);
41 data
= imageData
.data
;
42 shouldBe('data[0]', '255');
43 shouldBe('data[1]', '0');
44 shouldBe('data[2]', '0');
47 parent
.appendChild(canvas
);
48 parent
.removeChild(frame
);
50 imageData
= ctx
.getImageData(100, 100, 1, 1);
51 data
= imageData
.data
;
53 shouldBe('data[0]', '255');
55 // GC causes active DOM stop and canvas loses its context.
56 shouldBe('data[0]', '0');
58 shouldBe('data[1]', '0');
59 shouldBe('data[2]', '0');
63 <iframe id=
"frame1" src=
"resources/canvas-fill-for-iframe.html" onload=
"frameLoaded()"></iframe>
64 <iframe id=
"frame2" src=
"resources/canvas-fill-for-iframe.html" onload=
"frameLoaded()"></iframe>