Bug 1444614 - Avoid initializing gBrowser and gBrowser.tabContainer early in the urlbar binding constructor. r?gijs draft
authorDão Gottwald <dao@mozilla.com>
Sat, 10 Mar 2018 15:02:33 +0100
changeset 765882 7edf3d740fec1bf717cd151b1cf037b4a6b3a939
parent 765857 0817a733d45a48800e68c9e2a5035fd17bfcdee2
child 765885 7ee8b826b001bda6980fa2e755b38463341b81fe
push id102170
push userdgottwald@mozilla.com
push dateSat, 10 Mar 2018 14:02:59 +0000
reviewersgijs
bugs1444614
milestone60.0a1
Bug 1444614 - Avoid initializing gBrowser and gBrowser.tabContainer early in the urlbar binding constructor. r?gijs MozReview-Commit-ID: Lfv4d8RzhmZ
browser/base/content/browser.js
browser/base/content/urlbarBindings.xml
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1577,16 +1577,18 @@ var gBrowserInit = {
       // Enable the Restore Last Session command if needed
       RestoreLastSessionObserver.init();
 
       SidebarUI.startDelayedLoad();
 
       PanicButtonNotifier.init();
     });
 
+    gBrowser.tabContainer.addEventListener("TabSelect", gURLBar);
+
     gBrowser.tabContainer.addEventListener("TabSelect", function() {
       for (let panel of document.querySelectorAll("panel[tabspecific='true']")) {
         if (panel.state == "open") {
           panel.hidePopup();
         }
       }
     });
 
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -128,21 +128,16 @@ file, You can obtain one at http://mozil
         this.popup.addEventListener("popupshowing", () => {
           this.setAttribute("open", "true");
         });
         this.popup.addEventListener("popuphidden", () => {
           requestAnimationFrame(() => {
             this.removeAttribute("open");
           });
         });
-
-        // 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;
         }
@@ -1340,16 +1335,19 @@ file, You can obtain one at http://mozil
               }
               this.setAttribute("textoverflow", "true");
               break;
             case "underflow":
               this.removeAttribute("textoverflow");
               this._hideURLTooltip();
               break;
             case "TabSelect":
+              // 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.
               this.controller.resetInternalState();
               break;
           }
         ]]></body>
       </method>
 
       <!--
         onBeforeTextValueSet is called by the base-binding's .textValue getter.