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>
|
|
|
|
<script>
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
2016-03-04 07:23:20 +00:00
|
|
|
function createCanvas() {
|
|
|
|
var htmlCanvas = document.createElement('canvas');
|
2015-10-12 03:21:03 +00:00
|
|
|
ok(htmlCanvas, "Should have HTML canvas element");
|
2016-03-04 07:23:20 +00:00
|
|
|
ok(htmlCanvas.transferControlToOffscreen,
|
|
|
|
"HTMLCanvasElement has transferControlToOffscreen function");
|
|
|
|
htmlCanvas.width = 64;
|
|
|
|
htmlCanvas.height = 64;
|
|
|
|
document.body.appendChild(htmlCanvas);
|
|
|
|
return htmlCanvas;
|
|
|
|
}
|
2015-10-12 03:21:03 +00:00
|
|
|
|
2016-03-04 07:23:20 +00:00
|
|
|
function transferCtrlToOffscreen(canvas) {
|
|
|
|
var offscreencanvas = canvas.transferControlToOffscreen();
|
|
|
|
ok(offscreencanvas, "Expected transferControlToOffscreen to succeed");
|
|
|
|
return offscreencanvas;
|
|
|
|
}
|
2015-10-12 03:21:03 +00:00
|
|
|
|
2016-03-04 07:23:20 +00:00
|
|
|
function testShareWorker(worker, canvasType) {
|
|
|
|
var offscreenCanvas = transferCtrlToOffscreen(createCanvas());
|
2015-10-12 03:21:03 +00:00
|
|
|
|
|
|
|
// We don't support transferring OffscreenCanvas via shared worker.
|
|
|
|
SimpleTest.doesThrow(
|
|
|
|
function() {
|
2016-03-04 07:23:20 +00:00
|
|
|
worker.port.postMessage({canvasType: canvasType, testType: 'basic',
|
|
|
|
canvas: offscreenCanvas}, [offscreenCanvas]);
|
2015-10-12 03:21:03 +00:00
|
|
|
},
|
|
|
|
"OffscreenCanvas cannot transfer to shared worker"
|
|
|
|
);
|
2016-03-04 07:23:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function runTest() {
|
|
|
|
var worker = new SharedWorker("offscreencanvas.js");
|
|
|
|
ok(worker, "Web worker successfully created");
|
|
|
|
worker.port.start();
|
|
|
|
|
|
|
|
testShareWorker(worker, '2d');
|
|
|
|
testShareWorker(worker, 'webgl');
|
2015-10-12 03:21:03 +00:00
|
|
|
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
SpecialPowers.pushPrefEnv({'set': [
|
|
|
|
['gfx.offscreencanvas.enabled', true],
|
|
|
|
['webgl.force-enabled', true],
|
|
|
|
]}, runTest);
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|