Bug 1453280 - Clear and destroy tabbrowser tab's listener when adopting the last tab of a window. draft
authorLuca Greco <lgreco@mozilla.com>
Tue, 10 Apr 2018 23:09:28 +0200
changeset 780404 afcfaed50b0fc158fa2cc18be261411e4d9555d4
parent 780394 f6c3a0a19d82db25750d8badccd5cf37e79d028e
push id105986
push userluca.greco@alcacoop.it
push dateWed, 11 Apr 2018 11:17:19 +0000
bugs1453280
milestone61.0a1
Bug 1453280 - Clear and destroy tabbrowser tab's listener when adopting the last tab of a window. MozReview-Commit-ID: 4XA866P0HJl
browser/base/content/tabbrowser.js
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -2740,18 +2740,24 @@ window._gBrowser = {
       }
 
       newTab = true;
     }
     aTab._endRemoveArgs = [closeWindow, newTab];
 
     // swapBrowsersAndCloseOther will take care of closing the window without animation.
     if (closeWindow && aAdoptedByTab) {
-      // Remove the tab's filter to avoid leaking.
+      // Remove the tab's filter and progress listener to avoid leaking.
       if (aTab.linkedPanel) {
+        const filter = this._tabFilters.get(aTab);
+        browser.webProgress.removeProgressListener(filter);
+        const listener = this._tabListeners.get(aTab);
+        filter.removeProgressListener(listener);
+        listener.destroy();
+        this._tabListeners.delete(aTab);
         this._tabFilters.delete(aTab);
       }
       return true;
     }
 
     if (!aTab._fullyOpen) {
       // If the opening tab animation hasn't finished before we start closing the
       // tab, decrement the animation count since _handleNewTab will not get called.