4 <title>OffscreenCanvas: Test subworkers
</title>
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel=
"stylesheet" href=
"/tests/SimpleTest/test.css">
10 We want to test offscreen canvas works well when it running on worker
11 and nested worker simultaneously. So we create 10 canvas and dispatch
12 it to different workers and sub-workers.
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
);
23 return htmlCanvas
.transferControlToOffscreen();
28 var worker
= new Worker("offscreencanvas.js");
30 worker
.onmessage = function(evt
) {
31 var msg
= evt
.data
|| {};
32 if (msg
.type
== "test") {
33 ok(msg
.result
, msg
.name
);
35 if (msg
.type
== "finish") {
41 var findTransferables = function(t
) {
42 if (t
.test
== "subworker") {
44 t
.subtests
.forEach(function(test
) {
45 result
= result
.concat(findTransferables(test
));
55 {test
: 'subworker', subtests
: [
56 {test
: 'webgl', canvas
: createCanvas()},
57 {test
: 'subworker', subtests
: [
58 {test
: 'webgl', canvas
: createCanvas()},
59 {test
: 'webgl_changesize', canvas
: createCanvas()},
60 {test
: 'webgl', canvas
: createCanvas()}
62 {test
: 'subworker', subtests
: [
63 {test
: 'webgl', canvas
: createCanvas()},
64 {test
: 'webgl_changesize', canvas
: createCanvas()},
65 {test
: 'subworker', subtests
: [
66 {test
: 'webgl_changesize', canvas
: createCanvas()},
67 {test
: 'webgl', canvas
: createCanvas()}
69 {test
: 'subworker', subtests
: [
70 {test
: 'webgl_changesize', canvas
: createCanvas()},
71 {test
: 'subworker', subtests
: [
72 {test
: 'subworker', subtests
: [
73 {test
: 'webgl_changesize', canvas
: createCanvas()}
80 worker
.postMessage(testData
, findTransferables(testData
));
83 SpecialPowers
.pushPrefEnv({'set': [
84 ['webgl.force-enabled', true],