diff options
Diffstat (limited to 'devtools/shared/worker/tests')
3 files changed, 13 insertions, 19 deletions
diff --git a/devtools/shared/worker/tests/browser/browser_worker-01.js b/devtools/shared/worker/tests/browser/browser_worker-01.js index a8dafcf4cb..f8323e218e 100644 --- a/devtools/shared/worker/tests/browser/browser_worker-01.js +++ b/devtools/shared/worker/tests/browser/browser_worker-01.js @@ -3,8 +3,9 @@ "use strict"; -// Tests that the devtools/shared/worker communicates properly -// as both CommonJS module and as a JSM. +const { DevToolsWorker, workerify } = ChromeUtils.importESModule( + "resource://devtools/shared/worker/worker.sys.mjs" +); const BUFFER_SIZE = 8; @@ -15,22 +16,16 @@ registerCleanupFunction(function () { add_task(async function () { // Test both CJS and JSM versions - await testWorker("JSM", () => - ChromeUtils.import("resource://devtools/shared/worker/worker.js") - ); - await testWorker("CommonJS", () => - require("resource://devtools/shared/worker/worker.js") - ); + await testWorker(); await testTransfer(); }); -async function testWorker(context, workerFactory) { +async function testWorker() { // Needed for blob:null Services.prefs.setBoolPref( "security.allow_parent_unrestricted_js_loads", true ); - const { DevToolsWorker, workerify } = workerFactory(); const blob = new Blob( [ @@ -71,13 +66,13 @@ createTask(self, "groupByField", function({ is( Object.keys(results.groups).join(","), "France,Nigeria", - `worker should have returned the expected result in ${context}` + `worker should have returned the expected result` ); URL.revokeObjectURL(WORKER_URL); const fn = workerify(x => x * x); - is(await fn(5), 25, `workerify works in ${context}`); + is(await fn(5), 25, `workerify works`); fn.destroy(); worker.destroy(); @@ -88,9 +83,6 @@ async function testTransfer() { "security.allow_parent_unrestricted_js_loads", true ); - const { workerify } = ChromeUtils.import( - "resource://devtools/shared/worker/worker.js" - ); const workerFn = workerify(({ buf }) => buf.byteLength); const buf = new ArrayBuffer(BUFFER_SIZE); diff --git a/devtools/shared/worker/tests/browser/browser_worker-02.js b/devtools/shared/worker/tests/browser/browser_worker-02.js index 80c50cf887..c051946aee 100644 --- a/devtools/shared/worker/tests/browser/browser_worker-02.js +++ b/devtools/shared/worker/tests/browser/browser_worker-02.js @@ -5,9 +5,9 @@ // Tests errors are handled properly by the DevToolsWorker. -const { - DevToolsWorker, -} = require("resource://devtools/shared/worker/worker.js"); +const { DevToolsWorker } = ChromeUtils.importESModule( + "resource://devtools/shared/worker/worker.sys.mjs" +); const blob = new Blob( [ diff --git a/devtools/shared/worker/tests/browser/browser_worker-03.js b/devtools/shared/worker/tests/browser/browser_worker-03.js index 34e7688e73..9a7659979e 100644 --- a/devtools/shared/worker/tests/browser/browser_worker-03.js +++ b/devtools/shared/worker/tests/browser/browser_worker-03.js @@ -8,7 +8,9 @@ // // And tests `workerify` by doing so. -const { workerify } = require("resource://devtools/shared/worker/worker.js"); +const { workerify } = ChromeUtils.importESModule( + "resource://devtools/shared/worker/worker.sys.mjs" +); function square(x) { return x * x; } |