Skip to content

Commit

Permalink
A jsm file should not load using importESModule()
Browse files Browse the repository at this point in the history
  • Loading branch information
mhdzli committed Jul 19, 2024
1 parent 745cfad commit bbef9cb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 31 deletions.
58 changes: 28 additions & 30 deletions src/api/implementation.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
const { ExtensionCommon } = ChromeUtils.importESModule("resource://gre/modules/ExtensionCommon.sys.mjs");

const { ExtensionSupport } = function() {
for (const module of [
"resource:///modules/ExtensionSupport.sys.mjs", // v128
"resource:///modules/ExtensionSupport.jsm", // v115.10
]) {
try {
const m = ChromeUtils.importESModule(module);
console.log("ThreadPaneColumns", module);
return m;
} catch (ex) {
console.log("ThreadPaneColumns", module, ex);
}
}
return undefined;
}();
function loadSystemModule(newPath, oldPath) {
const errors = []
try {
return ChromeUtils.importESModule(newPath);
} catch (ex) {
errors.push(ex);
}
try {
return ChromeUtils.import(oldPath);
} catch (ex) {
errors.push(ex);
}
throw new Error(`Could not load system module: ${errors}`);
}

const { ExtensionSupport } = loadSystemModule("resource:///modules/ExtensionSupport.sys.mjs", "resource:///modules/ExtensionSupport.jsm");
const { ExtensionCommon } = loadSystemModule("resource://gre/modules/ExtensionCommon.sys.mjs", "resource://gre/modules/ExtensionCommon.jsm");
const { ThreadPaneColumns } = function() {
for (const module of [
"chrome://messenger/content/ThreadPaneColumns.mjs", // v128
"chrome://messenger/content/thread-pane-columns.mjs", // v115.10
]) {
try {
const m = ChromeUtils.importESModule(module);
console.log("ThreadPaneColumns", module);
return m;
} catch (ex) {
console.log("ThreadPaneColumns", module, ex);
}
}
return undefined;
const errors = []
for (const module of [
"chrome://messenger/content/ThreadPaneColumns.mjs", // v128
"chrome://messenger/content/thread-pane-columns.mjs", // v115.10
]) {
try {
return ChromeUtils.importESModule(module);
} catch (ex) {
errors.push(ex);
}
}
throw new Error(`Could not load system module: ${errors}`);
}();


Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Mahoor",
"description": "Adds a new Iranian(Persian/Jalali/Khorshidi) date column to ThunderBird.",
"version": "1.2.1",
"version": "1.2.2",
"homepage_url": "https://github.com/mhdzli/mahoor",
"author": "M.Zeinali",
"browser_specific_settings": {
Expand Down

0 comments on commit bbef9cb

Please sign in to comment.