Bug 1935611 - Fix libyuv/libpng link failed for loongarch64. r=glandium,tnikkel,ng
[gecko.git] / dom / canvas / test / test_offscreencanvas_neuter.html
blob9ac0fa02883d96afe5b030cd069b141aa3ca906a
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>OffscreenCanvas: Test neutering</title>
5 <script src="/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
7 </head>
8 <body>
9 <canvas id="c" width="64" height="64"></canvas>
10 <script>
12 SimpleTest.waitForExplicitFinish();
14 function runTest() {
16 var htmlCanvas = document.getElementById("c");
17 var worker = new Worker("offscreencanvas_neuter.js");
19 ok(htmlCanvas, "Should have HTML canvas element");
20 ok(worker, "Web worker successfully created");
22 ok(htmlCanvas.transferControlToOffscreen, "HTMLCanvasElement has transferControlToOffscreen function");
24 var offscreenCanvas = htmlCanvas.transferControlToOffscreen();
25 ok(offscreenCanvas, "Expected transferControlToOffscreen to succeed");
27 /* check html canvas is neuterd */
28 is(htmlCanvas.width, 64, "HTML canvas has correct width");
29 SimpleTest.doesThrow(
30 function() { htmlCanvas.width = 128; },
31 "Can't change html canvas' width after transferControlToOffscreen");
33 SimpleTest.doesThrow(
34 function() { htmlCanvas.height = 128; },
35 "Can't change html canvas' height after transferControlToOffscreen");
37 ok(!htmlCanvas.getContext("2d"), "Can't getContext after transferControlToOffscreen");
38 ok(!htmlCanvas.getContext("webgl"), "Can't getContext after transferControlToOffscreen");
39 ok(!htmlCanvas.getContext("webgl2"), "Can't getContext after transferControlToOffscreen");
41 worker.postMessage(offscreenCanvas, [offscreenCanvas]);
43 /* check parent offscreencanvas is neutered after being transfered */
44 SimpleTest.doesThrow(
45 function() { offscreenCanvas.width = 128; },
46 "Can't change transfered worker canvas width");
48 SimpleTest.doesThrow(
49 function() { offscreenCanvas.height = 128; },
50 "Can't change transfered worker canvas height");
52 SimpleTest.doesThrow(
53 function() { offscreenCanvas.getContext("2d") },
54 "Can't getContext on transfered worker canvas");
56 SimpleTest.doesThrow(
57 function() { offscreenCanvas.getContext("webgl") },
58 "Can't getContext on transfered worker canvas");
60 SimpleTest.doesThrow(
61 function() { offscreenCanvas.getContext("webgl2") },
62 "Can't getContext on transfered worker canvas");
64 // Transfer a neutered offscreencanvas should be ok.
65 worker.postMessage(offscreenCanvas, [offscreenCanvas]);
67 worker.terminate();
68 SimpleTest.finish();
71 SpecialPowers.pushPrefEnv({'set': [
72 ['webgl.force-enabled', true],
73 ]}, runTest);
75 </script>
76 </body>
77 </html>