From 6667e485013e0bc199c37d88fa974eb455f2e532 Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Mon, 10 Oct 2022 22:22:02 +0000 Subject: [PATCH] Bug 1793227, part 7 - Manual fixes for XPCOMUtils.sys.mjs. r=kmag One place was missing an explicit return. The eslint-disable-next-line is needed because the analysis doesn't seem to understand the non-static string. The return was split into a separate line because that made eslint complain that we needed to be consistent about returns, though the return type of defineModuleGetter is undefined. Finally, I updated the ChromeUtils.import() calls so they weren't using the deprecated argument. Differential Revision: https://phabricator.services.mozilla.com/D158506 --- js/xpconnect/loader/XPCOMUtils.sys.mjs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/js/xpconnect/loader/XPCOMUtils.sys.mjs b/js/xpconnect/loader/XPCOMUtils.sys.mjs index 109eb91f3234..517ebccf778c 100644 --- a/js/xpconnect/loader/XPCOMUtils.sys.mjs +++ b/js/xpconnect/loader/XPCOMUtils.sys.mjs @@ -55,6 +55,7 @@ export var XPCOMUtils = { redefining = true; return redefine(aObject, aName, aLambda.apply(aObject)); } + return undefined; }, configurable: true, enumerable: true, @@ -124,6 +125,7 @@ export var XPCOMUtils = { this.defineLazyGetter(aObject, name, () => { if (!(name in global)) { let importName = EXTRA_GLOBAL_NAME_TO_IMPORT_NAME[name] || name; + // eslint-disable-next-line mozilla/reject-importGlobalProperties, no-unused-vars Cu.importGlobalProperties([importName]); } return global[name]; @@ -216,7 +218,8 @@ export var XPCOMUtils = { aProxy ) { if (arguments.length == 3) { - return ChromeUtils.defineModuleGetter(aObject, aName, aResource); + ChromeUtils.defineModuleGetter(aObject, aName, aResource); + return; } let proxy = aProxy || {}; @@ -228,7 +231,7 @@ export var XPCOMUtils = { this.defineLazyGetter(aObject, aName, () => { var temp = {}; try { - ChromeUtils.import(aResource, temp); + temp = ChromeUtils.import(aResource); if (typeof aPostLambda === "function") { aPostLambda.apply(proxy); @@ -459,11 +462,7 @@ export var XPCOMUtils = { let initFunc = aInitFuncOrResource; if (typeof aInitFuncOrResource == "string") { - initFunc = function() { - let tmp = {}; - ChromeUtils.import(aInitFuncOrResource, tmp); - return tmp[aName]; - }; + initFunc = () => ChromeUtils.import(aInitFuncOrResource)[aName]; } let handler = new LazyProxyHandler(