diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /browser/components/search/test/browser/browser_hiddenOneOffs_diacritics.js | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/search/test/browser/browser_hiddenOneOffs_diacritics.js')
-rw-r--r-- | browser/components/search/test/browser/browser_hiddenOneOffs_diacritics.js | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/browser/components/search/test/browser/browser_hiddenOneOffs_diacritics.js b/browser/components/search/test/browser/browser_hiddenOneOffs_diacritics.js new file mode 100644 index 0000000000..38e309df10 --- /dev/null +++ b/browser/components/search/test/browser/browser_hiddenOneOffs_diacritics.js @@ -0,0 +1,74 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +// Tests that keyboard navigation in the search panel works as designed. + +const searchPopup = document.getElementById("PopupSearchAutoComplete"); + +const diacritic_engine = "Foo \u2661"; + +var { Preferences } = ChromeUtils.importESModule( + "resource://gre/modules/Preferences.sys.mjs" +); + +let searchIcon; + +add_setup(async function() { + let searchbar = await gCUITestUtils.addSearchBar(); + registerCleanupFunction(() => { + gCUITestUtils.removeSearchBar(); + }); + searchIcon = searchbar.querySelector(".searchbar-search-button"); + + let defaultEngine = await Services.search.getDefault(); + await SearchTestUtils.promiseNewSearchEngine({ + url: getRootDirectory(gTestPath) + "testEngine_diacritics.xml", + }); + registerCleanupFunction(async () => { + await Services.search.setDefault( + defaultEngine, + Ci.nsISearchService.CHANGE_REASON_UNKNOWN + ); + Services.prefs.clearUserPref("browser.search.hiddenOneOffs"); + }); +}); + +add_task(async function test_hidden() { + Preferences.set("browser.search.hiddenOneOffs", diacritic_engine); + + let promise = promiseEvent(searchPopup, "popupshown"); + info("Opening search panel"); + EventUtils.synthesizeMouseAtCenter(searchIcon, {}); + await promise; + + ok( + !getOneOffs().some(x => x.getAttribute("tooltiptext") == diacritic_engine), + "Search engines with diacritics are hidden when added to hiddenOneOffs preference." + ); + + promise = promiseEvent(searchPopup, "popuphidden"); + info("Closing search panel"); + EventUtils.synthesizeKey("KEY_Escape"); + await promise; +}); + +add_task(async function test_shown() { + Preferences.set("browser.search.hiddenOneOffs", ""); + + let oneOffsContainer = searchPopup.searchOneOffsContainer; + let shownPromise = promiseEvent(searchPopup, "popupshown"); + let builtPromise = promiseEvent(oneOffsContainer, "rebuild"); + info("Opening search panel"); + + EventUtils.synthesizeMouseAtCenter(searchIcon, {}); + await Promise.all([shownPromise, builtPromise]); + + ok( + getOneOffs().some(x => x.getAttribute("tooltiptext") == diacritic_engine), + "Search engines with diacritics are shown when removed from hiddenOneOffs preference." + ); + + let promise = promiseEvent(searchPopup, "popuphidden"); + searchPopup.hidePopup(); + await promise; +}); |