diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /browser/components/customizableui/test/browser_694291_searchbar_preference.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/customizableui/test/browser_694291_searchbar_preference.js')
-rw-r--r-- | browser/components/customizableui/test/browser_694291_searchbar_preference.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/browser/components/customizableui/test/browser_694291_searchbar_preference.js b/browser/components/customizableui/test/browser_694291_searchbar_preference.js new file mode 100644 index 0000000000..f65d8f0adc --- /dev/null +++ b/browser/components/customizableui/test/browser_694291_searchbar_preference.js @@ -0,0 +1,48 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const WIDGET_ID = "search-container"; +const PREF_NAME = "browser.search.widget.inNavBar"; + +function checkDefaults() { + ok(!Services.prefs.getBoolPref(PREF_NAME)); + is(CustomizableUI.getPlacementOfWidget(WIDGET_ID), null); +} + +add_task(async function test_defaults() { + // Verify the default state before the first test. + checkDefaults(); +}); + +add_task(async function test_syncPreferenceWithWidget() { + // Moving the widget to any position in the navigation toolbar should turn the + // preference to true. + CustomizableUI.addWidgetToArea(WIDGET_ID, CustomizableUI.AREA_NAVBAR); + ok(Services.prefs.getBoolPref(PREF_NAME)); + + // Moving the widget to any position outside of the navigation toolbar should + // turn the preference back to false. + CustomizableUI.addWidgetToArea( + WIDGET_ID, + CustomizableUI.AREA_FIXED_OVERFLOW_PANEL + ); + ok(!Services.prefs.getBoolPref(PREF_NAME)); +}); + +add_task(async function test_syncWidgetWithPreference() { + // setting the preference should move the widget to the navigation toolbar and + // place it right after the location bar. + Services.prefs.setBoolPref(PREF_NAME, true); + let placement = CustomizableUI.getPlacementOfWidget(WIDGET_ID); + is(placement.area, CustomizableUI.AREA_NAVBAR); + is( + placement.position, + CustomizableUI.getPlacementOfWidget("urlbar-container").position + 1 + ); + + // This should move the widget back to the customization palette. + Services.prefs.setBoolPref(PREF_NAME, false); + checkDefaults(); +}); |