summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/menubar/browser_search_history.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/base/content/test/menubar/browser_search_history.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/base/content/test/menubar/browser_search_history.js')
-rw-r--r--browser/base/content/test/menubar/browser_search_history.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/browser/base/content/test/menubar/browser_search_history.js b/browser/base/content/test/menubar/browser_search_history.js
new file mode 100644
index 0000000000..06c1402362
--- /dev/null
+++ b/browser/base/content/test/menubar/browser_search_history.js
@@ -0,0 +1,56 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests the Search History option from the menubar starts Address Bar search
+ * mode for history.
+ */
+ChromeUtils.defineLazyGetter(this, "UrlbarTestUtils", () => {
+ const { UrlbarTestUtils: module } = ChromeUtils.importESModule(
+ "resource://testing-common/UrlbarTestUtils.sys.mjs"
+ );
+ module.init(this);
+ return module;
+});
+
+add_task(async function test_menu_search_history_with_window_open() {
+ info("Opening history menu");
+ let searchHistoryMenuEntry = document.getElementById("menu_searchHistory");
+
+ searchHistoryMenuEntry.doCommand();
+
+ await isUrlbarInHistorySearchMode(window);
+});
+
+add_task(async function test_menu_search_history_opens_new_window() {
+ let newWindowPromise = TestUtils.topicObserved(
+ "browser-delayed-startup-finished"
+ );
+
+ info(
+ "Executing command in untracked browser window (simulating non-browser window)."
+ );
+ BrowserWindowTracker.untrackForTestsOnly(window);
+ let searchHistoryMenuEntry = document.getElementById("menu_searchHistory");
+ searchHistoryMenuEntry.doCommand();
+ BrowserWindowTracker.track(window);
+
+ info("Waiting for new window to open.");
+ let [newWindow] = await newWindowPromise;
+ await isUrlbarInHistorySearchMode(newWindow);
+ await BrowserTestUtils.closeWindow(newWindow);
+});
+
+async function isUrlbarInHistorySearchMode(targetWin) {
+ is(
+ targetWin,
+ BrowserWindowTracker.getTopWindow(),
+ "Target window is top window."
+ );
+ await UrlbarTestUtils.promisePopupOpen(targetWin, () => {});
+
+ // Verify URLBar is in search mode with correct restriction
+ let searchMode = UrlbarUtils.searchModeForToken("^");
+ searchMode.entry = "historymenu";
+ await UrlbarTestUtils.assertSearchMode(targetWin, searchMode);
+}