4 <title>WebGL in OffscreenCanvas
</title>
7 <canvas id=
"c" width=
"64" height=
"64"></canvas>
9 function ok(expect
, msg
) {
10 parent
.postMessage({type
: "test", result
: !!expect
, name
: msg
}, "*");
13 var htmlCanvas
= document
.getElementById("c");
15 ok(htmlCanvas
, "Should have HTML canvas element");
17 var messageChannel
= new MessageChannel();
18 messageChannel
.port1
.onmessage = function(evt
) {
19 parent
.postMessage(evt
.data
, "*");
22 ok(htmlCanvas
.transferControlToOffscreen
, "HTMLCanvasElement has transferControlToOffscreen function");
24 var offscreenCanvas
= htmlCanvas
.transferControlToOffscreen();
25 ok(offscreenCanvas
, "Expected transferControlToOffscreen to succeed");
27 navigator
.serviceWorker
.ready
.then(function() {
28 navigator
.serviceWorker
.controller
.postMessage({test
: 'webgl', canvas
: offscreenCanvas
}, [offscreenCanvas
, messageChannel
.port2
]);