Bug 1387583 - Avoid leaking a window in SelectParentHelper. r?jaws draft
authorMike Conley <mconley@mozilla.com>
Thu, 10 Aug 2017 16:26:37 -0400
changeset 644334 1d5fe87cf147b7400d81cad234628fd44125e8e4
parent 644113 4d54ac07b8c97f0e6713dab2ba694023b5b2f3b5
child 725579 bf9a3c004140c32ffe1ba7220fac2434ffeacd99
push id73404
push usermconley@mozilla.com
push dateThu, 10 Aug 2017 20:54:37 +0000
reviewersjaws
bugs1387583
milestone57.0a1
Bug 1387583 - Avoid leaking a window in SelectParentHelper. r?jaws 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;