4 <title>WebGL in OffscreenCanvas
</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>
10 <canvas id=
"c-ref" width=
"64" height=
"64"></canvas>
13 SimpleTest
.waitForExplicitFinish();
15 function testToDataURL() {
17 // Fill c-ref with green color.
18 var c
= document
.getElementById("c-ref");
19 var ctx
= c
.getContext("2d");
20 ctx
.rect(0, 0, 64, 64);
21 ctx
.fillStyle
= "#00FF00";
23 var htmlCanvas
= document
.getElementById("c");
24 ok(c
.toDataURL() == htmlCanvas
.toDataURL(), "toDataURL should return a 64x64 green square");
29 var htmlCanvas
= document
.getElementById("c");
30 var worker
= new Worker("offscreencanvas.js");
32 ok(htmlCanvas
, "Should have HTML canvas element");
33 ok(worker
, "Web worker successfully created");
35 worker
.onmessage = function(evt
) {
36 var msg
= evt
.data
|| {};
37 if (msg
.type
== "test") {
38 ok(msg
.result
, msg
.name
);
40 if (msg
.type
== "finish") {
47 ok(htmlCanvas
.transferControlToOffscreen
, "HTMLCanvasElement has transferControlToOffscreen function");
49 var offscreenCanvas
= htmlCanvas
.transferControlToOffscreen();
50 ok(offscreenCanvas
, "Expected transferControlToOffscreen to succeed");
52 worker
.postMessage({test
: 'webgl', canvas
: offscreenCanvas
}, [offscreenCanvas
]);
55 SpecialPowers
.pushPrefEnv({'set': [
56 ['webgl.force-enabled', true],