4 <title>OffscreenCanvas: Test neutering
</title>
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel=
"stylesheet" href=
"/tests/SimpleTest/test.css">
9 <canvas id=
"c" width=
"64" height=
"64"></canvas>
12 SimpleTest
.waitForExplicitFinish();
16 var htmlCanvas
= document
.getElementById("c");
17 var worker
= new Worker("offscreencanvas_neuter.js");
19 ok(htmlCanvas
, "Should have HTML canvas element");
20 ok(worker
, "Web worker successfully created");
22 ok(htmlCanvas
.transferControlToOffscreen
, "HTMLCanvasElement has transferControlToOffscreen function");
24 var offscreenCanvas
= htmlCanvas
.transferControlToOffscreen();
25 ok(offscreenCanvas
, "Expected transferControlToOffscreen to succeed");
27 /* check html canvas is neuterd */
28 is(htmlCanvas
.width
, 64, "HTML canvas has correct width");
30 function() { htmlCanvas
.width
= 128; },
31 "Can't change html canvas' width after transferControlToOffscreen");
34 function() { htmlCanvas
.height
= 128; },
35 "Can't change html canvas' height after transferControlToOffscreen");
37 ok(!htmlCanvas
.getContext("2d"), "Can't getContext after transferControlToOffscreen");
38 ok(!htmlCanvas
.getContext("webgl"), "Can't getContext after transferControlToOffscreen");
39 ok(!htmlCanvas
.getContext("webgl2"), "Can't getContext after transferControlToOffscreen");
41 worker
.postMessage(offscreenCanvas
, [offscreenCanvas
]);
43 /* check parent offscreencanvas is neutered after being transfered */
45 function() { offscreenCanvas
.width
= 128; },
46 "Can't change transfered worker canvas width");
49 function() { offscreenCanvas
.height
= 128; },
50 "Can't change transfered worker canvas height");
53 function() { offscreenCanvas
.getContext("2d") },
54 "Can't getContext on transfered worker canvas");
57 function() { offscreenCanvas
.getContext("webgl") },
58 "Can't getContext on transfered worker canvas");
61 function() { offscreenCanvas
.getContext("webgl2") },
62 "Can't getContext on transfered worker canvas");
64 // Transfer a neutered offscreencanvas should be ok.
65 worker
.postMessage(offscreenCanvas
, [offscreenCanvas
]);
71 SpecialPowers
.pushPrefEnv({'set': [
72 ['webgl.force-enabled', true],