summaryrefslogtreecommitdiffstats
path: root/browser/components/customizableui/test/browser_searchbar_removal.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /browser/components/customizableui/test/browser_searchbar_removal.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/customizableui/test/browser_searchbar_removal.js')
-rw-r--r--browser/components/customizableui/test/browser_searchbar_removal.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/browser/components/customizableui/test/browser_searchbar_removal.js b/browser/components/customizableui/test/browser_searchbar_removal.js
new file mode 100644
index 0000000000..ac847c8a4c
--- /dev/null
+++ b/browser/components/customizableui/test/browser_searchbar_removal.js
@@ -0,0 +1,36 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const { SearchWidgetTracker } = ChromeUtils.importESModule(
+ "resource:///modules/SearchWidgetTracker.sys.mjs"
+);
+
+const SEARCH_BAR_PREF_NAME = "browser.search.widget.inNavBar";
+const SEARCH_BAR_LAST_USED_PREF_NAME = "browser.search.widget.lastUsed";
+
+add_task(async function checkSearchBarPresent() {
+ Services.prefs.setBoolPref(SEARCH_BAR_PREF_NAME, true);
+ Services.prefs.setStringPref(
+ SEARCH_BAR_LAST_USED_PREF_NAME,
+ new Date("2022").toISOString()
+ );
+
+ Assert.ok(
+ BrowserSearch.searchBar,
+ "Search bar should be present in the Nav bar"
+ );
+ SearchWidgetTracker._updateSearchBarVisibilityBasedOnUsage();
+ Assert.ok(
+ !BrowserSearch.searchBar,
+ "Search bar should not be present in the Nav bar"
+ );
+ Assert.equal(
+ Services.prefs.getBoolPref(SEARCH_BAR_PREF_NAME),
+ false,
+ "Should remove the search bar"
+ );
+ Services.prefs.clearUserPref(SEARCH_BAR_LAST_USED_PREF_NAME);
+ Services.prefs.clearUserPref(SEARCH_BAR_PREF_NAME);
+});