Skip to content

Commit bbef9cb

Browse files
committed
A jsm file should not load using importESModule()
1 parent 745cfad commit bbef9cb

File tree

2 files changed

+29
-31
lines changed

2 files changed

+29
-31
lines changed

src/api/implementation.js

+28-30
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
1-
const { ExtensionCommon } = ChromeUtils.importESModule("resource://gre/modules/ExtensionCommon.sys.mjs");
2-
3-
const { ExtensionSupport } = function() {
4-
for (const module of [
5-
"resource:///modules/ExtensionSupport.sys.mjs", // v128
6-
"resource:///modules/ExtensionSupport.jsm", // v115.10
7-
]) {
8-
try {
9-
const m = ChromeUtils.importESModule(module);
10-
console.log("ThreadPaneColumns", module);
11-
return m;
12-
} catch (ex) {
13-
console.log("ThreadPaneColumns", module, ex);
14-
}
15-
}
16-
return undefined;
17-
}();
1+
function loadSystemModule(newPath, oldPath) {
2+
const errors = []
3+
try {
4+
return ChromeUtils.importESModule(newPath);
5+
} catch (ex) {
6+
errors.push(ex);
7+
}
8+
try {
9+
return ChromeUtils.import(oldPath);
10+
} catch (ex) {
11+
errors.push(ex);
12+
}
13+
throw new Error(`Could not load system module: ${errors}`);
14+
}
1815

16+
const { ExtensionSupport } = loadSystemModule("resource:///modules/ExtensionSupport.sys.mjs", "resource:///modules/ExtensionSupport.jsm");
17+
const { ExtensionCommon } = loadSystemModule("resource://gre/modules/ExtensionCommon.sys.mjs", "resource://gre/modules/ExtensionCommon.jsm");
1918
const { ThreadPaneColumns } = function() {
20-
for (const module of [
21-
"chrome://messenger/content/ThreadPaneColumns.mjs", // v128
22-
"chrome://messenger/content/thread-pane-columns.mjs", // v115.10
23-
]) {
24-
try {
25-
const m = ChromeUtils.importESModule(module);
26-
console.log("ThreadPaneColumns", module);
27-
return m;
28-
} catch (ex) {
29-
console.log("ThreadPaneColumns", module, ex);
30-
}
31-
}
32-
return undefined;
19+
const errors = []
20+
for (const module of [
21+
"chrome://messenger/content/ThreadPaneColumns.mjs", // v128
22+
"chrome://messenger/content/thread-pane-columns.mjs", // v115.10
23+
]) {
24+
try {
25+
return ChromeUtils.importESModule(module);
26+
} catch (ex) {
27+
errors.push(ex);
28+
}
29+
}
30+
throw new Error(`Could not load system module: ${errors}`);
3331
}();
3432

3533

src/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 2,
33
"name": "Mahoor",
44
"description": "Adds a new Iranian(Persian/Jalali/Khorshidi) date column to ThunderBird.",
5-
"version": "1.2.1",
5+
"version": "1.2.2",
66
"homepage_url": "https://github.com/mhdzli/mahoor",
77
"author": "M.Zeinali",
88
"browser_specific_settings": {

0 commit comments

Comments
 (0)