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
--- 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();
},