Bug 1399968 - Ensure the inNavBar search pref really does get set correctly on startup. r?Gijs draft
authorMark Banner <standard8@mozilla.com>
Thu, 14 Sep 2017 20:59:32 +0100
changeset 664994 c8cd72fee9b668136657734d2b23dd377849797e
parent 664655 4702042aa919d5ae49dfe3ac5ee86507839b3c83
child 731624 465a32cd3dad1ec518f5efaf7547e771556c9d00
push id79895
push userbmo:standard8@mozilla.com
push dateThu, 14 Sep 2017 20:00:49 +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();
   },