2015-10-12 03:21:03 +00:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>WebGL in OffscreenCanvas</title>
|
|
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
|
|
|
|
</head>
|
|
|
|
<body>
|
2016-03-05 15:20:47 +00:00
|
|
|
<canvas id="c" width="64" height="64"></canvas>
|
2015-10-12 03:21:03 +00:00
|
|
|
<script>
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
2016-03-05 15:20:47 +00:00
|
|
|
function runTest() {
|
|
|
|
|
|
|
|
var htmlCanvas = document.getElementById("c");
|
|
|
|
var worker = new SharedWorker("offscreencanvas.js");
|
|
|
|
|
2015-10-12 03:21:03 +00:00
|
|
|
ok(htmlCanvas, "Should have HTML canvas element");
|
2016-03-05 15:20:47 +00:00
|
|
|
ok(worker, "Web worker successfully created");
|
2015-10-12 03:21:03 +00:00
|
|
|
|
2016-03-05 15:20:47 +00:00
|
|
|
ok(htmlCanvas.transferControlToOffscreen, "HTMLCanvasElement has transferControlToOffscreen function");
|
|
|
|
|
|
|
|
var offscreenCanvas = htmlCanvas.transferControlToOffscreen();
|
|
|
|
ok(offscreenCanvas, "Expected transferControlToOffscreen to succeed");
|
2015-10-12 03:21:03 +00:00
|
|
|
|
2016-03-05 15:20:47 +00:00
|
|
|
worker.port.start();
|
2015-10-12 03:21:03 +00:00
|
|
|
|
|
|
|
// We don't support transferring OffscreenCanvas via shared worker.
|
|
|
|
SimpleTest.doesThrow(
|
|
|
|
function() {
|
2016-03-05 15:20:47 +00:00
|
|
|
worker.port.postMessage({test: 'webgl', canvas: offscreenCanvas}, [offscreenCanvas]);
|
2015-10-12 03:21:03 +00:00
|
|
|
},
|
|
|
|
"OffscreenCanvas cannot transfer to shared worker"
|
|
|
|
);
|
|
|
|
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
SpecialPowers.pushPrefEnv({'set': [
|
|
|
|
['gfx.offscreencanvas.enabled', true],
|
|
|
|
['webgl.force-enabled', true],
|
|
|
|
]}, runTest);
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|