1 onmessage = async event => {
2 if (event.data.order === "test") {
3 globalThis["loaded"] = [];
4 const ns = await import("resource://test/non_shared_1.mjs");
9 if (event.data.order === "sync-before-async") {
10 globalThis["loaded"] = [];
11 const ns = ChromeUtils.importESModule("resource://test/non_shared_1.mjs", {
15 const sync_beforeInc = ns.getCounter();
17 const sync_afterInc = ns.getCounter();
19 const loaded1 = globalThis["loaded"].join(",");
22 if (event.data.target === "top-level") {
23 nsPromise = import("resource://test/non_shared_1.mjs");
25 nsPromise = import("resource://test/import_non_shared_1.mjs");
28 const ns2 = await nsPromise;
30 const async_beforeInc = ns2.getCounter();
32 const async_afterInc = ns2.getCounter();
33 const sync_afterIncInc = ns.getCounter();
35 const loaded2 = globalThis["loaded"].join(",");
49 if (event.data.order === "sync-after-async") {
50 globalThis["loaded"] = [];
51 const ns = await import("resource://test/non_shared_1.mjs");
53 const async_beforeInc = ns.getCounter();
55 const async_afterInc = ns.getCounter();
57 const loaded1 = globalThis["loaded"].join(",");
60 if (event.data.target === "top-level") {
61 ns2 = ChromeUtils.importESModule("resource://test/non_shared_1.mjs", {
65 ns2 = ChromeUtils.importESModule("resource://test/import_non_shared_1.mjs", {
70 const sync_beforeInc = ns2.getCounter();
72 const sync_afterInc = ns2.getCounter();
73 const async_afterIncInc = ns.getCounter();
75 const loaded2 = globalThis["loaded"].join(",");
89 if (event.data.order === "sync-while-async") {
90 globalThis["loaded"] = [];
91 const nsPromise = import("resource://test/non_shared_1.mjs");
93 let errorMessage = "";
95 if (event.data.target === "top-level") {
96 ChromeUtils.importESModule("resource://test/non_shared_1.mjs", {
100 ChromeUtils.importESModule("resource://test/import_non_shared_1.mjs", {
105 errorMessage = e.message;
108 const ns = await nsPromise;
110 const async_beforeInc = ns.getCounter();
112 const async_afterInc = ns.getCounter();
114 const loaded = globalThis["loaded"].join(",");
117 sync_error: errorMessage,