diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /browser/base/content/test/menubar/browser_search_bookmarks.js | |
parent | Initial commit. (diff) | |
download | firefox-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_bookmarks.js')
-rw-r--r-- | browser/base/content/test/menubar/browser_search_bookmarks.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/browser/base/content/test/menubar/browser_search_bookmarks.js b/browser/base/content/test/menubar/browser_search_bookmarks.js new file mode 100644 index 0000000000..1c0da6071e --- /dev/null +++ b/browser/base/content/test/menubar/browser_search_bookmarks.js @@ -0,0 +1,60 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Tests the Search Bookmarks option from the menubar starts Address Bar search + * mode for bookmarks. + */ +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_bookmarks_with_window_open() { + info("Opening bookmarks menu"); + let searchBookmarksMenuEntry = document.getElementById( + "menu_searchBookmarks" + ); + + searchBookmarksMenuEntry.doCommand(); + + await isUrlbarInBookmarksSearchMode(window); +}); + +add_task(async function test_menu_search_bookmarks_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 searchBookmarksMenuEntry = document.getElementById( + "menu_searchBookmarks" + ); + searchBookmarksMenuEntry.doCommand(); + BrowserWindowTracker.track(window); + + info("Waiting for new window to open."); + let [newWindow] = await newWindowPromise; + await isUrlbarInBookmarksSearchMode(newWindow); + await BrowserTestUtils.closeWindow(newWindow); +}); + +async function isUrlbarInBookmarksSearchMode(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 = "bookmarkmenu"; + await UrlbarTestUtils.assertSearchMode(targetWin, searchMode); +} |