Bug 1387583 - Avoid leaking a window in SelectParentHelper. r=jaws, a=gchang
authorMike Conley <mconley@mozilla.com>
Thu, 10 Aug 2017 16:26:37 -0400
changeset 423657 9b28ea0fe4e5cf75867ece02ca120fb5f6e5e92f
parent 423656 e9b8e3fb359c0e8956c148e0b37081ba0ca594e6
child 423658 9e27747354e0c803482fb55f66beb448f3c19062
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws, gchang
bugs1387583
milestone56.0
Bug 1387583 - Avoid leaking a window in SelectParentHelper. r=jaws, a=gchang MozReview-Commit-ID: 6YILe7gi2fZ
toolkit/modules/SelectParentHelper.jsm
--- a/toolkit/modules/SelectParentHelper.jsm
+++ b/toolkit/modules/SelectParentHelper.jsm
@@ -13,21 +13,23 @@ const {AppConstants} = Cu.import("resour
 const {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
 
 // Maximum number of rows to display in the select dropdown.
 const MAX_ROWS = 20;
 
 // Minimum elements required to show select search
 const SEARCH_MINIMUM_ELEMENTS = 40;
 
+// Make sure to clear these objects when the popup closes to avoid leaking.
 var currentBrowser = null;
 var currentMenulist = null;
+var selectRect = null;
+
 var currentZoom = 1;
 var closedWithEnter = false;
-var selectRect;
 var customStylingEnabled = Services.prefs.getBoolPref("dom.forms.select.customstyling");
 var usedSelectBackgroundColor;
 
 this.SelectParentHelper = {
   populate(menulist, items, selectedIndex, zoom, uaBackgroundColor, uaColor,
            uaSelectBackgroundColor, uaSelectColor, selectBackgroundColor, selectColor,
            selectTextShadow) {
     // Clear the current contents of the popup
@@ -178,16 +180,17 @@ this.SelectParentHelper = {
 
       case "popuphidden":
         currentBrowser.messageManager.sendAsyncMessage("Forms:DismissedDropDown", {});
         let popup = event.target;
         this._unregisterListeners(currentBrowser, popup);
         popup.parentNode.hidden = true;
         currentBrowser = null;
         currentMenulist = null;
+        selectRect = null;
         currentZoom = 1;
         break;
     }
   },
 
   receiveMessage(msg) {
     if (!currentBrowser) {
       return;