summaryrefslogtreecommitdiffstats
path: root/js/xpconnect/tests/unit/es6module_devtoolsLoader.sys.mjs
blob: c8262f5f5c091db8d68fab4e0d31851aea6c3157 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
export let x = 0;

export function increment() {
  x++;
};

import { object } from "resource://test/es6module_devtoolsLoader.js";
export const importedObject = object;

const importDevTools = ChromeUtils.importESModule("resource://test/es6module_devtoolsLoader.js", { global: "devtools" });
export const importESModuleDevTools = importDevTools.object;

const importShared = ChromeUtils.importESModule("resource://test/es6module_devtoolsLoader.js", { global: "shared" });
export const importESModuleShared = importShared.object;

const importCurrent = ChromeUtils.importESModule("resource://test/es6module_devtoolsLoader.js", { global: "current" });
export const importESModuleCurrent = importCurrent.object;

const importContextual = ChromeUtils.importESModule("resource://test/es6module_devtoolsLoader.js", { global: "contextual" });
export const importESModuleContextual = importContextual.object;

let caught = false;
try {
  ChromeUtils.importESModule("resource://test/es6module_devtoolsLoader.js");
} catch (e) {
  caught = true;
}
export const importESModuleNoOptionFailed1 = caught;

caught = false;
try {
  ChromeUtils.importESModule("resource://test/es6module_devtoolsLoader.js", {});
} catch (e) {
  caught = true;
}
export const importESModuleNoOptionFailed2 = caught;

const lazyDevTools = {};
ChromeUtils.defineESModuleGetters(lazyDevTools, {
  object: "resource://test/es6module_devtoolsLoader.js",
}, { global: "devtools" });

export function importLazyDevTools() {
  return lazyDevTools.object;
}

const lazyShared = {};
ChromeUtils.defineESModuleGetters(lazyShared, {
  object: "resource://test/es6module_devtoolsLoader.js",
}, { global: "shared" });

export function importLazyShared() {
  return lazyShared.object;
}

const lazyCurrent = {};
ChromeUtils.defineESModuleGetters(lazyCurrent, {
  object: "resource://test/es6module_devtoolsLoader.js",
}, { global: "current" });

export function importLazyCurrent() {
  return lazyCurrent.object;
}

const lazyContextual = {};
ChromeUtils.defineESModuleGetters(lazyContextual, {
  object: "resource://test/es6module_devtoolsLoader.js",
}, { global: "contextual" });

export function importLazyContextual() {
  return lazyContextual.object;
}

caught = false;
try {
  let lazy = {};
  ChromeUtils.defineESModuleGetters({}, {
    object: "resource://test/es6module_devtoolsLoader.js",
  });
} catch (e) {
  caught = true;
}
export const importLazyNoOptionFailed1 = caught;

caught = false;
try {
  let lazy = {};
  ChromeUtils.defineESModuleGetters({}, {
    object: "resource://test/es6module_devtoolsLoader.js",
  }, {});
} catch (e) {
  caught = true;
}
export const importLazyNoOptionFailed2 = caught;