summaryrefslogtreecommitdiffstats
path: root/js/xpconnect/tests/unit/test_import_devtools_loader.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /js/xpconnect/tests/unit/test_import_devtools_loader.js
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/xpconnect/tests/unit/test_import_devtools_loader.js')
-rw-r--r--js/xpconnect/tests/unit/test_import_devtools_loader.js28
1 files changed, 18 insertions, 10 deletions
diff --git a/js/xpconnect/tests/unit/test_import_devtools_loader.js b/js/xpconnect/tests/unit/test_import_devtools_loader.js
index d7e6fe42f6..f3518ca301 100644
--- a/js/xpconnect/tests/unit/test_import_devtools_loader.js
+++ b/js/xpconnect/tests/unit/test_import_devtools_loader.js
@@ -39,19 +39,27 @@ add_task(async function testDevToolsModuleLoader() {
dbg.addDebuggee(nsGlobal);
Assert.ok(true, "The global is accepted by the Debugger API");
- const ns1 = ChromeUtils.importESModule(ESM_URL, { loadInDevToolsLoader : false });
- Assert.equal(ns1, ns, "Passing loadInDevToolsLoader=false from the shared JSM global is equivalent to regular importESModule");
+ const ns1 = ChromeUtils.importESModule(ESM_URL, { global: "shared" });
+ Assert.equal(ns1, ns, "Passing global: 'shared' from the shared JSM global is equivalent to regular importESModule");
info("Test importing in the devtools loader");
- const ns2 = ChromeUtils.importESModule(ESM_URL, { loadInDevToolsLoader: true });
+ const ns2 = ChromeUtils.importESModule(ESM_URL, { global: "devtools" });
Assert.equal(ns2.x, 0, "We get a new module instance with a new incremented number");
Assert.notEqual(ns2, ns, "We imported a new instance of the module");
Assert.notEqual(ns2.importedObject, ns.importedObject, "The two module instances expose distinct objects");
- Assert.equal(ns2.importESModuleTrue, ns2.importedObject, "When using loadInDevToolsLoader:true from a devtools global, we keep loading in the same loader");
- Assert.equal(ns2.importESModuleNull, ns2.importedObject, "When having an undefined loadInDevToolsLoader from a devtools global, we keep loading in the same loader");
- Assert.equal(ns2.importESModuleNull2, ns2.importedObject, "When having no optional argument at all, we keep loading in the same loader");
- Assert.equal(ns2.importESModuleFalse, ns.importedObject, "When passing an explicit loadInDevToolsLoader:false, we load in the shared global, even from a devtools global");
- Assert.equal(ns2.importLazy(), ns2.importedObject, "ChromeUtils.defineESModuleGetters imports will follow the contextual loader");
+ Assert.equal(ns2.importESModuleDevTools, ns2.importedObject, "When using global: 'devtools' from a devtools global, we keep loading in the same loader");
+ Assert.equal(ns2.importESModuleCurrent, ns2.importedObject, "When using global: 'current' from a devtools global, we keep loading in the same loader");
+ Assert.equal(ns2.importESModuleContextual, ns2.importedObject, "When using global: 'contextual' from a devtools global, we keep loading in the same loader");
+ Assert.ok(ns2.importESModuleNoOptionFailed1, "global option is required in DevTools global");
+ Assert.ok(ns2.importESModuleNoOptionFailed2, "global option is required in DevTools global");
+ Assert.equal(ns2.importESModuleShared, ns.importedObject, "When passing global: 'shared', we load in the shared global, even from a devtools global");
+
+ Assert.equal(ns2.importLazyDevTools(), ns2.importedObject, "When using global: 'devtools' from a devtools global, we keep loading in the same loader");
+ Assert.equal(ns2.importLazyCurrent(), ns2.importedObject, "When using global: 'current' from a devtools global, we keep loading in the same loader");
+ Assert.equal(ns2.importLazyContextual(), ns2.importedObject, "When using global: 'contextual' from a devtools global, we keep loading in the same loader");
+ Assert.ok(ns2.importLazyNoOptionFailed1, "global option is required in DevTools global");
+ Assert.ok(ns2.importLazyNoOptionFailed2, "global option is required in DevTools global");
+ Assert.equal(ns2.importLazyShared(), ns.importedObject, "When passing global: 'shared', we load in the shared global, even from a devtools global");
info("When using the devtools loader, we load in a distinct global, but the same compartment");
const ns2Global = Cu.getGlobalForObject(ns2);
@@ -63,12 +71,12 @@ add_task(async function testDevToolsModuleLoader() {
"Global os ESM loaded in the devtools loader can't be inspected by the Debugee");
info("Re-import the same module in the devtools loader");
- const ns3 = ChromeUtils.importESModule(ESM_URL, { loadInDevToolsLoader: true });
+ const ns3 = ChromeUtils.importESModule(ESM_URL, { global: "devtools" });
Assert.equal(ns3, ns2, "We import the exact same module");
Assert.equal(ns3.importedObject, ns2.importedObject, "The two module expose the same objects");
info("Import a module only from the devtools loader");
- const ns4 = ChromeUtils.importESModule("resource://test/es6module_devtoolsLoader_only.js", { loadInDevToolsLoader: true });
+ const ns4 = ChromeUtils.importESModule("resource://test/es6module_devtoolsLoader_only.js", { global: "devtools" });
const ns4Global = Cu.getGlobalForObject(ns4);
Assert.equal(ns4Global, ns2Global, "The module is loaded in the same devtools global");