Bug 1283262 Make AutoCompleteE10S clear its popup cache when the associated browser window is closed. r=mrbkap
authorBen Kelly <ben@wanderview.com>
Tue, 19 Jul 2016 17:12:42 -0700
changeset 330819 4de50147d99cb9c51d11f0eaaac6663950f381ee
parent 330818 a46d84c52f89110162c4f292d646521bd6efc676
child 330820 402ae3d3dec6f6b6dddca251adfb4457598bd8bc
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs1283262
milestone50.0a1
Bug 1283262 Make AutoCompleteE10S clear its popup cache when the associated browser window is closed. r=mrbkap
toolkit/components/satchel/AutoCompleteE10S.jsm
--- a/toolkit/components/satchel/AutoCompleteE10S.jsm
+++ b/toolkit/components/satchel/AutoCompleteE10S.jsm
@@ -86,31 +86,48 @@ this.AutoCompleteE10S = {
     messageManager.addMessageListener("FormAutoComplete:GetSelectedIndex", this);
     messageManager.addMessageListener("FormAutoComplete:MaybeOpenPopup", this);
     messageManager.addMessageListener("FormAutoComplete:ClosePopup", this);
     messageManager.addMessageListener("FormAutoComplete:Disconnect", this);
     messageManager.addMessageListener("FormAutoComplete:RemoveEntry", this);
   },
 
   _initPopup: function(browserWindow, rect, direction) {
+    if (this._popupCache) {
+      this._popupCache.browserWindow.removeEventListener("unload", this);
+    }
+    browserWindow.addEventListener("unload", this);
+
     this._popupCache = { browserWindow, rect, direction };
 
     this.browser = browserWindow.gBrowser.selectedBrowser;
     this.popup = this.browser.autoCompletePopup;
     this.popup.hidden = false;
     // don't allow the popup to become overly narrow
     this.popup.setAttribute("width", Math.max(100, rect.width));
     this.popup.style.direction = direction;
 
     this.x = rect.left;
     this.y = rect.top;
     this.width = rect.width;
     this.height = rect.height;
   },
 
+  handleEvent: function(evt) {
+    if (evt.type === "unload") {
+      this._uninitPopup();
+    }
+  },
+
+  _uninitPopup: function() {
+    this._popupCache = null;
+    this.browser = null;
+    this.popup = null;
+  },
+
   _showPopup: function(results) {
     AutoCompleteE10SView.clearResults();
 
     let resultsArray = [];
     let count = results.matchCount;
     for (let i = 0; i < count; i++) {
       // The actual result for each match in the results object is the value.
       // We return that in order to submit the correct value. However, we have