summaryrefslogtreecommitdiffstats
path: root/js/xpconnect/tests/unit/test_import_global_contextual.js
blob: 817f00fc45e179a12a64c206ecf9b5b8afdbd76d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

add_task(async function testInNonShared() {
  const ns1 = ChromeUtils.importESModule("resource://test/esmified-1.sys.mjs");

  const ns2 = ChromeUtils.importESModule("resource://test/esmified-1.sys.mjs", {
    global: "contextual",
  });

  Assert.equal(ns1, ns2);
  Assert.equal(ns1.obj, ns2.obj);
});

add_task(async function testInShared() {
  const { ns: ns1 } = ChromeUtils.importESModule("resource://test/contextual.sys.mjs");

  const ns2 = ChromeUtils.importESModule("resource://test/esmified-1.sys.mjs", {
    global: "shared",
  });

  Assert.equal(ns1, ns2);
  Assert.equal(ns1.obj, ns2.obj);
});

add_task(async function testInShared() {
  const { ns: ns1 } = ChromeUtils.importESModule("resource://test/contextual.sys.mjs", {
    global: "devtools",
  });

  const ns2 = ChromeUtils.importESModule("resource://test/esmified-1.sys.mjs", {
    global: "devtools",
  });

  Assert.equal(ns1, ns2);
  Assert.equal(ns1.obj, ns2.obj);
});