1 Services.prefs.setBoolPref("browser.startup.record", true);
2 registerCleanupFunction(() => {
3 Services.prefs.clearUserPref("browser.startup.record");
6 add_task(function test_JSModule() {
7 const URL = "resource://test/import_stack.jsm";
8 ChromeUtils.import(URL);
9 Assert.ok(Cu.getModuleImportStack(URL).includes("test_JSModule"));
12 add_task(function test_ESModule() {
13 const URL = "resource://test/import_stack.sys.mjs";
14 ChromeUtils.importESModule(URL);
15 Assert.ok(Cu.getModuleImportStack(URL).includes("test_ESModule"));
18 add_task(function test_ESModule_static_import() {
19 const URL1 = "resource://test/import_stack_static_1.sys.mjs";
20 const URL2 = "resource://test/import_stack_static_2.sys.mjs";
21 const URL3 = "resource://test/import_stack_static_3.sys.mjs";
22 const URL4 = "resource://test/import_stack_static_4.sys.mjs";
24 ChromeUtils.importESModule(URL1);
26 Assert.ok(Cu.getModuleImportStack(URL1).includes("test_ESModule_static"));
28 Assert.ok(Cu.getModuleImportStack(URL2).includes("test_ESModule_static"));
29 Assert.ok(Cu.getModuleImportStack(URL2).includes(URL1));
31 Assert.ok(Cu.getModuleImportStack(URL3).includes("test_ESModule_static"));
32 Assert.ok(Cu.getModuleImportStack(URL3).includes(URL1));
33 Assert.ok(Cu.getModuleImportStack(URL3).includes(URL2));
35 Assert.ok(Cu.getModuleImportStack(URL4).includes("test_ESModule_static"));
36 Assert.ok(Cu.getModuleImportStack(URL4).includes(URL1));
37 Assert.ok(Cu.getModuleImportStack(URL4).includes(URL2));
38 Assert.ok(Cu.getModuleImportStack(URL4).includes(URL3));