Bug 1213975 - fix WebExtension tabs.onUpdated cleanup on context close. r=billm
authorLuca Greco <luca.greco@alcacoop.it>
Mon, 26 Oct 2015 04:56:00 +0100
changeset 304906 148a40aae385d23a8a5ab6ee55bd89777f559c34
parent 304905 b3a33728ece55fea9dc343a7ef59f58e1c80133c
child 304907 4437a28d2e47ff262870b81382f038288fabb910
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1213975
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1213975 - fix WebExtension tabs.onUpdated cleanup on context close. r=billm
browser/components/extensions/ext-tabs.js
browser/components/extensions/ext-utils.js
--- a/browser/components/extensions/ext-tabs.js
+++ b/browser/components/extensions/ext-tabs.js
@@ -214,21 +214,22 @@ extensions.registerAPI((extension, conte
             }
           },
         };
 
         AllWindowEvents.addListener("progress", progressListener);
         AllWindowEvents.addListener("TabAttrModified", listener);
         AllWindowEvents.addListener("TabPinned", listener);
         AllWindowEvents.addListener("TabUnpinned", listener);
+
         return () => {
           AllWindowEvents.removeListener("progress", progressListener);
-          AllWindowEvents.addListener("TabAttrModified", listener);
-          AllWindowEvents.addListener("TabPinned", listener);
-          AllWindowEvents.addListener("TabUnpinned", listener);
+          AllWindowEvents.removeListener("TabAttrModified", listener);
+          AllWindowEvents.removeListener("TabPinned", listener);
+          AllWindowEvents.removeListener("TabUnpinned", listener);
         };
       }).api(),
 
       onReplaced: ignoreEvent(),
 
       onRemoved: new EventManager(context, "tabs.onRemoved", fire => {
         let tabListener = event => {
           let tab = event.originalTarget;
--- a/browser/components/extensions/ext-utils.js
+++ b/browser/components/extensions/ext-utils.js
@@ -525,17 +525,17 @@ global.AllWindowEvents = {
     if (type == "domwindowopened") {
       return WindowListManager.removeOpenListener(listener);
     } else if (type == "domwindowclosed") {
       return WindowListManager.removeCloseListener(listener);
     }
 
     let listeners = this._listeners.get(type);
     listeners.delete(listener);
-    if (listeners.length == 0) {
+    if (listeners.size == 0) {
       this._listeners.delete(type);
       if (this._listeners.size == 0) {
         WindowListManager.removeOpenListener(this.openListener);
       }
     }
 
     for (let window of WindowListManager.browserWindows()) {
       if (type == "progress") {