Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / js / xpconnect / tests / mochitest / test_shadowRealm_worker.html
blobd26e665f8f2d38919626b6fccf9945448637bcad
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>Test for ShadowRealms</title>
6 <script src="/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
8 <iframe id="ifr"></iframe>
9 </head>
11 <body>
12 <p id="display"></p>
13 <script type="application/javascript">
14 SimpleTest.waitForExplicitFinish();
16 var promise = (async ()=> {
17 var module = await import("./shadow_realm_module.js");
18 is(module.x, 1, "import works outside worker");
20 var sr = new ShadowRealm();
21 await sr.importValue("./shadow_realm_module.js", 'x').then((x) => is(x,1, "imported x and got 1"));
22 })();
24 promise.then(() => {
25 var worker = new Worker("shadow_realm_worker.js");
27 var expected = 0;
28 var recieved = 0;
30 function test(str) {
31 worker.postMessage(str);
32 expected++;
35 worker.onmessage = function(e) {
36 console.log("Received Message: "+e.data);
37 recieved++;
39 if (e.data == "finish") {
40 is(expected, recieved, "Got the appropriate Number of messages");
41 SimpleTest.finish();
42 return;
45 if (e.data.startsWith("PASS")) {
46 ok(true, e.data);
47 return;
50 ok(false, e.data);
54 test("evaluate");
55 test("import");
58 test("finish");
59 });
60 </script>
61 </body>
63 </html>