Bug 1399968 - Ensure the inNavBar search pref really does get set correctly on startup. r=Gijs
authorMark Banner <standard8@mozilla.com>
Thu, 14 Sep 2017 20:59:32 +0100
changeset 665594 956bc408307c40ffc9a307a7affe8377e04842aa
parent 665593 a71dd9ce8a166bf5781ecbc53ead54bd50f4f8f2
child 665595 d3df8bc53dcb46cd30426d14f668cb5ab36c85c9
push id80115
push userbmo:eoger@fastmail.com
push dateFri, 15 Sep 2017 18:29:01 +0000
reviewersGijs
bugs1399968
milestone57.0a1
Bug 1399968 - Ensure the inNavBar search pref really does get set correctly on startup. r=Gijs Delay the initialisation of the pref until the toolbar has been initialised. MozReview-Commit-ID: JxQajZ4wrCR
browser/components/customizableui/SearchWidgetTracker.jsm
--- a/browser/components/customizableui/SearchWidgetTracker.jsm
+++ b/browser/components/customizableui/SearchWidgetTracker.jsm
@@ -31,20 +31,25 @@ const SearchWidgetTracker = {
     this.onWidgetReset = this.onWidgetUndoMove = node => {
       if (node.id == WIDGET_ID) {
         this.syncPreferenceWithWidget();
       }
     };
     CustomizableUI.addListener(this);
     Services.prefs.addObserver(PREF_NAME,
                                () => this.syncWidgetWithPreference());
+  },
 
+  onAreaNodeRegistered(aArea) {
     // The placement of the widget always takes priority, and the preference
-    // should always match the actual placement when the browser starts up.
-    this.syncPreferenceWithWidget();
+    // should always match the actual placement when the browser starts up - i.e.
+    // once the navigation bar has been registered.
+    if (aArea == CustomizableUI.AREA_NAVBAR) {
+      this.syncPreferenceWithWidget();
+    }
   },
 
   onCustomizeEnd() {
     // onWidgetUndoMove does not fire when the search container is moved back to
     // the customization palette as a result of an undo, so we sync again here.
     this.syncPreferenceWithWidget();
   },