4 <title>WebGL in OffscreenCanvas
</title>
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel=
"stylesheet" href=
"/tests/SimpleTest/test.css">
10 This test needs several workers run offscreen canvas simultaneously.
11 So we choose 8 workers, 4 of them run basic webgl drawing test and
12 others run size changing test.
16 SimpleTest
.waitForExplicitFinish();
18 function createCanvas() {
19 var htmlCanvas
= document
.createElement('canvas');
20 htmlCanvas
.width
= 64;
21 htmlCanvas
.height
= 64;
22 document
.body
.appendChild(htmlCanvas
);
29 var startWorker = function(canvas
, test
) {
31 var worker
= new Worker("offscreencanvas.js");
33 worker
.onmessage = function(evt
) {
34 var msg
= evt
.data
|| {};
35 if (msg
.type
== "test") {
36 ok(msg
.result
, msg
.name
);
38 if (msg
.type
== "finish") {
40 if (--stillRunning
== 0)
45 var offscreenCanvas
= canvas
.transferControlToOffscreen();
46 worker
.postMessage({test
, canvas
: offscreenCanvas
}, [offscreenCanvas
]);
49 /* create 4 workers that do the regular drawing test and 4 workers
50 that do the size change test */
51 for (var i
= 0; i
< 4; i
++) {
52 startWorker(createCanvas(), 'webgl');
55 for (var i
= 0; i
< 4; i
++) {
56 startWorker(createCanvas(), 'webgl_changesize');
60 SpecialPowers
.pushPrefEnv({'set': [
61 ['webgl.force-enabled', true]