Bug 1434045 - avoid errors when XBL destructors fire without the constructor having fired, r?florian draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 14 Feb 2018 10:21:05 +0000
changeset 754801 d04c8b82ba4ddd7262953d18afdf4a60599f08ce
parent 754572 e43f2f6ea111c2d059d95fa9a71516b869a69698
push id99002
push usergijskruitbosch@gmail.com
push dateWed, 14 Feb 2018 10:21:40 +0000
reviewersflorian
bugs1434045
milestone60.0a1
Bug 1434045 - avoid errors when XBL destructors fire without the constructor having fired, r?florian MozReview-Commit-ID: B9rWp4TEoqX
browser/base/content/urlbarBindings.xml
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -136,16 +136,21 @@ file, You can obtain one at http://mozil
 
         // The autocomplete controller uses heuristic on some internal caches
         // to handle cases like backspace, autofill or repeated searches.
         // Ensure to clear those internal caches when switching tabs.
         gBrowser.tabContainer.addEventListener("TabSelect", this);
       ]]></constructor>
 
       <destructor><![CDATA[
+        // Somehow, it's possible for the XBL destructor to fire without the
+        // constructor ever having fired. Fix:
+        if (!this._prefs) {
+          return;
+        }
         this._prefs.removeObserver("", this);
         this._prefs = null;
         Services.prefs.removeObserver("browser.search.suggest.enabled", this);
         this.inputField.controllers.removeController(this._copyCutController);
         this.inputField.removeEventListener("paste", this);
         this.inputField.removeEventListener("mousedown", this);
         this.inputField.removeEventListener("mousemove", this);
         this.inputField.removeEventListener("mouseout", this);