2 Any copyright is dedicated to the Public Domain.
3 http://creativecommons.org/publicdomain/zero/1.0/
8 Tests of Worker Dynamic Import (Bug 1540913)
9 Ensure that the script loader doesn't fail if requests are terminated early.
12 <title>Test for Worker Dynamic Import (Bug
1540913)
</title>
13 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
14 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
16 <body onload=
"onLoad()">
17 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=1540913">Worker Dynamic Import
20 <div id=
"content" style=
"display: none">
24 <script class=
"testbody" type=
"text/javascript">
25 SimpleTest.waitForExplicitFinish();
27 async function onLoad() {
28 await SpecialPowers.pushPrefEnv(
29 { set: [[
"dom.workers.modules.enabled", true ]] });
32 new Worker(
"dynamicImport_worker.js", {type:
"classic"}),
33 new Worker(
"dynamicImport_worker.js", {type:
"module"})
38 // In the implementation of dynamic import, every dynamic import has
39 // it's own ScriptLoader. To ensure that this is working correctly,
40 // this tests that if we re-order the dynamic import order,
41 // worker termination works as expected.
42 for (const worker of workers) {
44 worker.onmessage = function(event) {
47 ok(false,
"first dynamic import returned");
51 ok(events.length ===
0,
52 "second dynamic import returned");
53 events.push(event.data);
56 // Cheap way to make sure we only finish successfully after
57 // both the module and classic test is finished.
58 if (successCount ==
2) {
63 ok(false,
"Unexpected message:" + event.data);
68 worker.onerror = function(event) {
69 ok(false,
"Worker had an error:" + event.message);
73 worker.postMessage(
"start");