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/. */
5 add_task(async function testShared() {
9 ChromeUtils.defineESModuleGetters(lazy1, {
10 GetX: "resource://test/esm_lazy-1.sys.mjs",
13 ChromeUtils.defineESModuleGetters(lazy2, {
14 GetX: "resource://test/esm_lazy-1.sys.mjs",
19 Assert.equal(lazy1.GetX, lazy2.GetX);
21 const ns = ChromeUtils.importESModule("resource://test/esm_lazy-1.sys.mjs");
23 Assert.equal(ns.GetX, lazy1.GetX);
24 Assert.equal(ns.GetX, lazy2.GetX);
27 add_task(async function testDevTools() {
30 ChromeUtils.defineESModuleGetters(lazy, {
31 GetX: "resource://test/esm_lazy-1.sys.mjs",
36 lazy.GetX; // delazify before import.
38 const ns = ChromeUtils.importESModule("resource://test/esm_lazy-1.sys.mjs", {
42 Assert.equal(ns.GetX, lazy.GetX);
45 add_task(async function testSandbox() {
46 const uri = "http://example.com/";
47 const window = createContentWindow(uri);
49 sandboxPrototype: window,
50 wantGlobalProperties: ["ChromeUtils"],
52 const sb = new Cu.Sandbox(uri, sandboxOpts);
54 const result = Cu.evalInSandbox(`
57 ChromeUtils.defineESModuleGetters(lazy, {
58 GetX: "resource://test/esm_lazy-1.sys.mjs",
63 lazy.GetX; // delazify before import.
65 const ns = ChromeUtils.importESModule("resource://test/esm_lazy-1.sys.mjs", {
75 add_task(async function testWindow() {
76 const win1 = createChromeWindow();
78 const result = win1.eval(`
81 ChromeUtils.defineESModuleGetters(lazy, {
82 GetX: "resource://test/esm_lazy-1.sys.mjs",
87 lazy.GetX; // delazify before import.
89 const ns = ChromeUtils.importESModule("resource://test/esm_lazy-1.sys.mjs", {