Bug 1319567 fix window id so it is never zero, r?kmag
MozReview-Commit-ID: 30u1o1BOAvv
--- a/browser/components/extensions/ext-utils.js
+++ b/browser/components/extensions/ext-utils.js
@@ -919,19 +919,16 @@ TabManager.for = function(extension) {
/* eslint-disable mozilla/balanced-listeners */
extensions.on("shutdown", (type, extension) => {
tabManagers.delete(extension);
});
/* eslint-enable mozilla/balanced-listeners */
// Manages mapping between XUL windows and extension window IDs.
global.WindowManager = {
- _windows: new WeakMap(),
- _nextId: 0,
-
// Note: These must match the values in windows.json.
WINDOW_ID_NONE: -1,
WINDOW_ID_CURRENT: -2,
get topWindow() {
return Services.wm.getMostRecentWindow("navigator:browser");
},
@@ -960,22 +957,21 @@ global.WindowManager = {
if (options.width !== null || options.height !== null) {
let width = options.width !== null ? options.width : window.outerWidth;
let height = options.height !== null ? options.height : window.outerHeight;
window.resizeTo(width, height);
}
},
getId(window) {
- if (this._windows.has(window)) {
- return this._windows.get(window);
+ if (!window.QueryInterface) {
+ return null;
}
- let id = this._nextId++;
- this._windows.set(window, id);
- return id;
+ return window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
},
getWindow(id, context) {
if (id == this.WINDOW_ID_CURRENT) {
return currentWindow(context);
}
for (let window of WindowListManager.browserWindows(true)) {