Bug 1453280 - Clear and destroy tabbrowser tab's listener when adopting the last tab of a window. r=dao
authorLuca Greco <lgreco@mozilla.com>
Tue, 10 Apr 2018 23:09:28 +0200
changeset 414347 67cef646951c79d7eef1f3d3d3ad713ef6be5f24
parent 414346 a3c07c7bfce3ca859fafdf7fc194c23ba1f67fc9
child 414348 116248a2b4acf6bc08800a5da9497e6a73fbd0d5
push id102317
push userbtara@mozilla.com
push dateWed, 18 Apr 2018 22:47:42 +0000
treeherdermozilla-inbound@c8b6fba2ae94 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao
bugs1453280
milestone61.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 1453280 - Clear and destroy tabbrowser tab's listener when adopting the last tab of a window. r=dao 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.