test_import_global_contextual.js (1152B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 add_task(async function testInNonShared() { 6 const ns1 = ChromeUtils.importESModule("resource://test/esmified-1.sys.mjs"); 7 8 const ns2 = ChromeUtils.importESModule("resource://test/esmified-1.sys.mjs", { 9 global: "contextual", 10 }); 11 12 Assert.equal(ns1, ns2); 13 Assert.equal(ns1.obj, ns2.obj); 14 }); 15 16 add_task(async function testInShared() { 17 const { ns: ns1 } = ChromeUtils.importESModule("resource://test/contextual.sys.mjs"); 18 19 const ns2 = ChromeUtils.importESModule("resource://test/esmified-1.sys.mjs", { 20 global: "shared", 21 }); 22 23 Assert.equal(ns1, ns2); 24 Assert.equal(ns1.obj, ns2.obj); 25 }); 26 27 add_task(async function testInShared() { 28 const { ns: ns1 } = ChromeUtils.importESModule("resource://test/contextual.sys.mjs", { 29 global: "devtools", 30 }); 31 32 const ns2 = ChromeUtils.importESModule("resource://test/esmified-1.sys.mjs", { 33 global: "devtools", 34 }); 35 36 Assert.equal(ns1, ns2); 37 Assert.equal(ns1.obj, ns2.obj); 38 });