From 0eb0708a5b0e3a30cda630ba9d9441c423b32c8d Mon Sep 17 00:00:00 2001 From: gorhill Date: Thu, 22 Oct 2015 18:27:24 -0400 Subject: [PATCH] code review: only clients of win watcher care about window type --- platform/firefox/vapi-background.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index fd683c29c..566dd1a7a 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -580,6 +580,7 @@ var winWatcher = (function() { } addWindow(win); }, + onCloseWindow: function(aWindow) { var win; try { @@ -589,6 +590,7 @@ var winWatcher = (function() { } removeWindow(win); }, + observe: function(aSubject, topic) { // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWindowWatcher#registerNotification%28%29 // "aSubject - the window being opened or closed, sent as an @@ -613,10 +615,10 @@ var winWatcher = (function() { }; (function() { - var win, winumerator, docElement; + var winumerator, win; // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWindowMediator#getEnumerator%28%29 - winumerator = Services.wm.getEnumerator(chromeWindowType); + winumerator = Services.wm.getEnumerator(null); while ( winumerator.hasMoreElements() ) { win = winumerator.getNext(); if ( !win.closed ) { @@ -630,14 +632,7 @@ var winWatcher = (function() { win = winumerator.getNext() .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIDOMWindow); - if ( win.closed ) { - continue; - } - docElement = win.document && win.document.documentElement; - if ( !docElement ) { - continue; - } - if ( docElement.getAttribute('windowtype') === chromeWindowType ) { + if ( !win.closed ) { windowToIdMap.set(win, windowIdGenerator++); } }