From 9d6669eb1e085e08bd37e383414a45713618fec0 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Tue, 1 Jul 2025 17:04:22 -0400 Subject: [PATCH] fx140: Add ChromeUtils.import() shim for plugins We can decide if we want to keep this, but it's an easy change that seems useful for dev builds. --- chrome/content/zotero/xpcom/plugins.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/chrome/content/zotero/xpcom/plugins.js b/chrome/content/zotero/xpcom/plugins.js index 5e8db7a29f..616828a12c 100644 --- a/chrome/content/zotero/xpcom/plugins.js +++ b/chrome/content/zotero/xpcom/plugins.js @@ -174,6 +174,22 @@ Zotero.Plugins = new function () { } ); + // fx140: Shim ChromeUtils.import() in the plugin scope + // TODO: Do we want this? + scope.ChromeUtils = new Proxy(scope.ChromeUtils, { + get(target, property, receiver) { + if (property === 'import') { + return function (uri) { + let esmURI = uri.replace('.jsm', uri.includes('/zotero/') ? '.mjs' : '.sys.mjs'); + Zotero.warn('ChromeUtils.import() has been removed. Use importESModule():\n' + + ` ChromeUtils.importESModule("${esmURI}");`); + return receiver.importESModule(esmURI); + }; + } + return Reflect.get(target, property, receiver); + } + }); + scopes.set(addon.id, scope); try {