Bug 1387583 - Avoid leaking a window in SelectParentHelper. r?jaws
MozReview-Commit-ID: 6YILe7gi2fZ
--- 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;