Bug 1935611 - Fix libyuv/libpng link failed for loongarch64. r=glandium,tnikkel,ng
[gecko.git] / dom / canvas / test / test_offscreencanvas_basic_webgl.html
blob52beb948691ebebba661b8239bdff5af126dd9ed
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>WebGL in OffscreenCanvas</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 <canvas id="c-ref" width="64" height="64"></canvas>
11 <script>
13 SimpleTest.waitForExplicitFinish();
15 function testToDataURL() {
16 // testing toDataURL
17 // Fill c-ref with green color.
18 var c = document.getElementById("c-ref");
19 var ctx = c.getContext("2d");
20 ctx.rect(0, 0, 64, 64);
21 ctx.fillStyle = "#00FF00";
22 ctx.fill();
23 var htmlCanvas = document.getElementById("c");
24 ok(c.toDataURL() == htmlCanvas.toDataURL(), "toDataURL should return a 64x64 green square");
27 function runTest() {
29 var htmlCanvas = document.getElementById("c");
30 var worker = new Worker("offscreencanvas.js");
32 ok(htmlCanvas, "Should have HTML canvas element");
33 ok(worker, "Web worker successfully created");
35 worker.onmessage = function(evt) {
36 var msg = evt.data || {};
37 if (msg.type == "test") {
38 ok(msg.result, msg.name);
40 if (msg.type == "finish") {
41 testToDataURL();
42 worker.terminate();
43 SimpleTest.finish();
47 ok(htmlCanvas.transferControlToOffscreen, "HTMLCanvasElement has transferControlToOffscreen function");
49 var offscreenCanvas = htmlCanvas.transferControlToOffscreen();
50 ok(offscreenCanvas, "Expected transferControlToOffscreen to succeed");
52 worker.postMessage({test: 'webgl', canvas: offscreenCanvas}, [offscreenCanvas]);
55 SpecialPowers.pushPrefEnv({'set': [
56 ['webgl.force-enabled', true],
57 ]}, runTest);
59 </script>
60 </body>
61 </html>