Bug 1398630: Part 4 - Use getWinUtils everywhere we use DOMWindowUtils. r?zombie
MozReview-Commit-ID: FroMQF9Tiz1
--- a/toolkit/components/extensions/ExtensionChild.jsm
+++ b/toolkit/components/extensions/ExtensionChild.jsm
@@ -39,16 +39,17 @@ Cu.import("resource://gre/modules/Extens
const {
DefaultMap,
EventEmitter,
LimitedSet,
defineLazyGetter,
getMessageManager,
getUniqueId,
+ getWinUtils,
withHandlingUserInput,
} = ExtensionUtils;
const {
EventManager,
LocalAPIImplementation,
LocaleData,
NoCloneSpreadArgs,
@@ -679,18 +680,17 @@ class ProxyAPIImplementation extends Sch
callFunctionNoReturn(args) {
this.childApiManager.callParentFunctionNoReturn(this.path, args);
}
callAsyncFunction(args, callback, requireUserInput) {
if (requireUserInput) {
let context = this.childApiManager.context;
- let winUtils = context.contentWindow.getInterface(Ci.nsIDOMWindowUtils);
- if (!winUtils.isHandlingUserInput) {
+ if (!getWinUtils(context.contentWindow).isHandlingUserInput) {
let err = new context.cloneScope.Error(`${this.path} may only be called from a user input handler`);
return context.wrapPromise(Promise.reject(err), callback);
}
}
return this.childApiManager.callParentAsyncFunction(this.path, args, callback);
}
addListener(listener, args) {
--- a/toolkit/components/extensions/ExtensionCommon.jsm
+++ b/toolkit/components/extensions/ExtensionCommon.jsm
@@ -41,16 +41,17 @@ var {
DefaultWeakMap,
EventEmitter,
ExtensionError,
defineLazyGetter,
filterStack,
getConsole,
getInnerWindowID,
getUniqueId,
+ getWinUtils,
} = ExtensionUtils;
XPCOMUtils.defineLazyGetter(this, "console", getConsole);
var ExtensionCommon;
/**
* A sentinel class to indicate that an array of values should be
@@ -663,19 +664,17 @@ class LocalAPIImplementation extends Sch
callFunctionNoReturn(args) {
this.pathObj[this.name](...args);
}
callAsyncFunction(args, callback, requireUserInput) {
let promise;
try {
if (requireUserInput) {
- let winUtils = this.context.contentWindow
- .getInterface(Ci.nsIDOMWindowUtils);
- if (!winUtils.isHandlingUserInput) {
+ if (!getWinUtils(this.context.contentWindow).isHandlingUserInput) {
throw new ExtensionError(`${this.name} may only be called from a user input handler`);
}
}
promise = this.pathObj[this.name](...args) || Promise.resolve();
} catch (e) {
promise = Promise.reject(e);
}
return this.context.wrapPromise(promise, callback);
--- a/toolkit/components/extensions/ext-tabs-base.js
+++ b/toolkit/components/extensions/ext-tabs-base.js
@@ -1201,18 +1201,16 @@ class WindowTrackerBase extends EventEmi
this._listeners = new DefaultMap(() => new Set());
this._statusListeners = new DefaultWeakMap(listener => {
return new StatusListener(listener);
});
this._windowIds = new DefaultWeakMap(window => {
- window.QueryInterface(Ci.nsIInterfaceRequestor);
-
return getWinUtils(window).outerWindowID;
});
}
isBrowserWindow(window) {
let {documentElement} = window.document;
return documentElement.getAttribute("windowtype") === "navigator:browser";
--- a/toolkit/components/extensions/ext-theme.js
+++ b/toolkit/components/extensions/ext-theme.js
@@ -6,16 +6,20 @@ Cu.import("resource://gre/modules/Servic
XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager",
"resource://gre/modules/LightweightThemeManager.jsm");
XPCOMUtils.defineLazyGetter(this, "gThemesEnabled", () => {
return Services.prefs.getBoolPref("extensions.webextensions.themes.enabled");
});
+var {
+ getWinUtils,
+} = ExtensionUtils;
+
const ICONS = Services.prefs.getStringPref("extensions.webextensions.themes.icons.buttons", "").split(",");
/** Class representing a theme. */
class Theme {
/**
* Creates a theme instance.
*
* @param {string} baseURI The base URI of the extension, used to
@@ -38,19 +42,17 @@ class Theme {
*
* @param {Object} details Theme part of the manifest. Supported
* properties can be found in the schema under ThemeType.
* @param {Object} targetWindow The window to apply the theme to. Omitting
* this parameter will apply the theme globally.
*/
load(details, targetWindow) {
if (targetWindow) {
- this.lwtStyles.window = targetWindow
- .QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
+ this.lwtStyles.window = getWinUtils(targetWindow).outerWindowID;
}
if (details.colors) {
this.loadColors(details.colors);
}
if (details.images) {
this.loadImages(details.images);