Bug 1103068 - Stop leaking due to a strong reference held by the nsBrowserStatusFilter r=billm
authorTim Taubert <ttaubert@mozilla.com>
Sun, 23 Nov 2014 10:28:20 +0100
changeset 241641 1010735871641aaee854270be4d320bfd510a479
parent 241532 16a220a579a67420a0f57ab20c8ca41a0d30a65a
child 241642 2baabecada385d86f1e3601aaa6250603fda44b3
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1103068
milestone36.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 1103068 - Stop leaking due to a strong reference held by the nsBrowserStatusFilter r=billm
toolkit/content/browser-child.js
--- a/toolkit/content/browser-child.js
+++ b/toolkit/content/browser-child.js
@@ -42,16 +42,25 @@ let WebProgressListener = {
                      .createInstance(Ci.nsIWebProgress);
     this._filter.addProgressListener(this, Ci.nsIWebProgress.NOTIFY_ALL);
 
     let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
                               .getInterface(Ci.nsIWebProgress);
     webProgress.addProgressListener(this._filter, Ci.nsIWebProgress.NOTIFY_ALL);
   },
 
+  uninit() {
+    let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
+                              .getInterface(Ci.nsIWebProgress);
+    webProgress.removeProgressListener(this._filter);
+
+    this._filter.removeProgressListener(this);
+    this._filter = null;
+  },
+
   _requestSpec: function (aRequest, aPropertyName) {
     if (!aRequest || !(aRequest instanceof Ci.nsIChannel))
       return null;
     return aRequest.QueryInterface(Ci.nsIChannel)[aPropertyName].spec;
   },
 
   _setupJSON: function setupJSON(aWebProgress, aRequest) {
     if (aWebProgress) {
@@ -149,16 +158,19 @@ let WebProgressListener = {
         return this;
     }
 
     throw Components.results.NS_ERROR_NO_INTERFACE;
   }
 };
 
 WebProgressListener.init();
+addEventListener("unload", () => {
+  WebProgressListener.uninit();
+});
 
 let WebNavigation =  {
   init: function() {
     addMessageListener("WebNavigation:GoBack", this);
     addMessageListener("WebNavigation:GoForward", this);
     addMessageListener("WebNavigation:GotoIndex", this);
     addMessageListener("WebNavigation:LoadURI", this);
     addMessageListener("WebNavigation:Reload", this);