1 add_task(function test_JSModule() {
2 const URL1 = "resource://test/jsm_loaded-1.jsm";
3 const URL2 = "resource://test/jsm_loaded-2.jsm";
4 const URL3 = "resource://test/jsm_loaded-3.jsm";
6 Assert.ok(!Cu.loadedJSModules.includes(URL1));
7 Assert.ok(!Cu.isJSModuleLoaded(URL1));
8 Assert.ok(!Cu.loadedJSModules.includes(URL2));
9 Assert.ok(!Cu.isJSModuleLoaded(URL2));
10 Assert.ok(!Cu.loadedJSModules.includes(URL3));
11 Assert.ok(!Cu.isJSModuleLoaded(URL3));
12 Assert.ok(!Cu.loadedESModules.includes(URL1));
13 Assert.ok(!Cu.isESModuleLoaded(URL1));
14 Assert.ok(!Cu.loadedESModules.includes(URL2));
15 Assert.ok(!Cu.isESModuleLoaded(URL2));
16 Assert.ok(!Cu.loadedESModules.includes(URL3));
17 Assert.ok(!Cu.isESModuleLoaded(URL3));
19 ChromeUtils.import(URL1);
21 Assert.ok(Cu.loadedJSModules.includes(URL1));
22 Assert.ok(Cu.isJSModuleLoaded(URL1));
23 Assert.ok(!Cu.loadedJSModules.includes(URL2));
24 Assert.ok(!Cu.isJSModuleLoaded(URL2));
25 Assert.ok(!Cu.loadedJSModules.includes(URL3));
26 Assert.ok(!Cu.isJSModuleLoaded(URL3));
27 Assert.ok(!Cu.loadedESModules.includes(URL1));
28 Assert.ok(!Cu.isESModuleLoaded(URL1));
29 Assert.ok(!Cu.loadedESModules.includes(URL2));
30 Assert.ok(!Cu.isESModuleLoaded(URL2));
31 Assert.ok(!Cu.loadedESModules.includes(URL3));
32 Assert.ok(!Cu.isESModuleLoaded(URL3));
34 ChromeUtils.import(URL2);
36 Assert.ok(Cu.loadedJSModules.includes(URL1));
37 Assert.ok(Cu.isJSModuleLoaded(URL1));
38 Assert.ok(Cu.loadedJSModules.includes(URL2));
39 Assert.ok(Cu.isJSModuleLoaded(URL2));
40 Assert.ok(!Cu.loadedJSModules.includes(URL3));
41 Assert.ok(!Cu.isJSModuleLoaded(URL3));
42 Assert.ok(!Cu.loadedESModules.includes(URL1));
43 Assert.ok(!Cu.isESModuleLoaded(URL1));
44 Assert.ok(!Cu.loadedESModules.includes(URL2));
45 Assert.ok(!Cu.isESModuleLoaded(URL2));
46 Assert.ok(!Cu.loadedESModules.includes(URL3));
47 Assert.ok(!Cu.isESModuleLoaded(URL3));
49 ChromeUtils.import(URL3);
51 Assert.ok(Cu.loadedJSModules.includes(URL1));
52 Assert.ok(Cu.isJSModuleLoaded(URL1));
53 Assert.ok(Cu.loadedJSModules.includes(URL2));
54 Assert.ok(Cu.isJSModuleLoaded(URL2));
55 Assert.ok(Cu.loadedJSModules.includes(URL3));
56 Assert.ok(Cu.isJSModuleLoaded(URL3));
57 Assert.ok(!Cu.loadedESModules.includes(URL1));
58 Assert.ok(!Cu.isESModuleLoaded(URL1));
59 Assert.ok(!Cu.loadedESModules.includes(URL2));
60 Assert.ok(!Cu.isESModuleLoaded(URL2));
61 Assert.ok(!Cu.loadedESModules.includes(URL3));
62 Assert.ok(!Cu.isESModuleLoaded(URL3));
65 add_task(function test_ESModule() {
66 const URL1 = "resource://test/es6module_loaded-1.sys.mjs";
67 const URL2 = "resource://test/es6module_loaded-2.sys.mjs";
68 const URL3 = "resource://test/es6module_loaded-3.sys.mjs";
70 Assert.ok(!Cu.loadedJSModules.includes(URL1));
71 Assert.ok(!Cu.isJSModuleLoaded(URL1));
72 Assert.ok(!Cu.loadedJSModules.includes(URL2));
73 Assert.ok(!Cu.isJSModuleLoaded(URL2));
74 Assert.ok(!Cu.loadedJSModules.includes(URL3));
75 Assert.ok(!Cu.isJSModuleLoaded(URL3));
76 Assert.ok(!Cu.loadedESModules.includes(URL1));
77 Assert.ok(!Cu.isESModuleLoaded(URL1));
78 Assert.ok(!Cu.loadedESModules.includes(URL2));
79 Assert.ok(!Cu.isESModuleLoaded(URL2));
80 Assert.ok(!Cu.loadedESModules.includes(URL3));
81 Assert.ok(!Cu.isESModuleLoaded(URL3));
83 ChromeUtils.importESModule(URL1);
85 Assert.ok(!Cu.loadedJSModules.includes(URL1));
86 Assert.ok(!Cu.isJSModuleLoaded(URL1));
87 Assert.ok(!Cu.loadedJSModules.includes(URL2));
88 Assert.ok(!Cu.isJSModuleLoaded(URL2));
89 Assert.ok(!Cu.loadedJSModules.includes(URL3));
90 Assert.ok(!Cu.isJSModuleLoaded(URL3));
91 Assert.ok(Cu.loadedESModules.includes(URL1));
92 Assert.ok(Cu.isESModuleLoaded(URL1));
93 Assert.ok(!Cu.loadedESModules.includes(URL2));
94 Assert.ok(!Cu.isESModuleLoaded(URL2));
95 Assert.ok(!Cu.loadedESModules.includes(URL3));
96 Assert.ok(!Cu.isESModuleLoaded(URL3));
98 ChromeUtils.importESModule(URL2);
100 Assert.ok(!Cu.loadedJSModules.includes(URL1));
101 Assert.ok(!Cu.isJSModuleLoaded(URL1));
102 Assert.ok(!Cu.loadedJSModules.includes(URL2));
103 Assert.ok(!Cu.isJSModuleLoaded(URL2));
104 Assert.ok(!Cu.loadedJSModules.includes(URL3));
105 Assert.ok(!Cu.isJSModuleLoaded(URL3));
106 Assert.ok(Cu.loadedESModules.includes(URL1));
107 Assert.ok(Cu.isESModuleLoaded(URL1));
108 Assert.ok(Cu.loadedESModules.includes(URL2));
109 Assert.ok(Cu.isESModuleLoaded(URL2));
110 Assert.ok(!Cu.loadedESModules.includes(URL3));
111 Assert.ok(!Cu.isESModuleLoaded(URL3));
113 ChromeUtils.importESModule(URL3);
115 Assert.ok(!Cu.loadedJSModules.includes(URL1));
116 Assert.ok(!Cu.isJSModuleLoaded(URL1));
117 Assert.ok(!Cu.loadedJSModules.includes(URL2));
118 Assert.ok(!Cu.isJSModuleLoaded(URL2));
119 Assert.ok(!Cu.loadedJSModules.includes(URL3));
120 Assert.ok(!Cu.isJSModuleLoaded(URL3));
121 Assert.ok(Cu.loadedESModules.includes(URL1));
122 Assert.ok(Cu.isESModuleLoaded(URL1));
123 Assert.ok(Cu.loadedESModules.includes(URL2));
124 Assert.ok(Cu.isESModuleLoaded(URL2));
125 Assert.ok(Cu.loadedESModules.includes(URL3));
126 Assert.ok(Cu.isESModuleLoaded(URL3));