diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
commit | da4c7e7ed675c3bf405668739c3012d140856109 (patch) | |
tree | cdd868dba063fecba609a1d819de271f0d51b23e /toolkit/components/search/tests/xpcshell/test_defaultEngine_fallback.js | |
parent | Adding upstream version 125.0.3. (diff) | |
download | firefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip |
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/search/tests/xpcshell/test_defaultEngine_fallback.js')
-rw-r--r-- | toolkit/components/search/tests/xpcshell/test_defaultEngine_fallback.js | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/toolkit/components/search/tests/xpcshell/test_defaultEngine_fallback.js b/toolkit/components/search/tests/xpcshell/test_defaultEngine_fallback.js index 12cb6568e7..2f269cc016 100644 --- a/toolkit/components/search/tests/xpcshell/test_defaultEngine_fallback.js +++ b/toolkit/components/search/tests/xpcshell/test_defaultEngine_fallback.js @@ -17,6 +17,15 @@ let appDefault; let appPrivateDefault; +async function getSearchConfig() { + let workDir = Services.dirsvc.get("CurWorkD", Ci.nsIFile); + let configFileName = + "file://" + PathUtils.join(workDir.path, "data", "search-config-v2.json"); + + let response = await fetch(configFileName); + return response.json(); +} + add_setup(async function () { useHttpServer(); await SearchTestUtils.useTestEngines(); @@ -292,10 +301,33 @@ add_task(async function test_default_fallback_remove_default_no_visible() { add_task( async function test_default_fallback_remove_default_no_visible_or_general() { - // Reset. Services.search.restoreDefaultEngines(); - Services.search.defaultEngine = Services.search.defaultPrivateEngine = - appPrivateDefault; + + // For this test, we need to change any general search engines to unknown, + // so that we can test what happens in the unlikely event that there are no + // general search engines. + if (SearchUtils.newSearchConfigEnabled) { + let searchConfig = await getSearchConfig(); + for (let entry of searchConfig.data) { + if ( + entry.recordType == "engine" && + entry.base.classification == "general" + ) { + entry.base.classification = "unknown"; + } + } + const settings = await RemoteSettings(SearchUtils.SETTINGS_KEY); + settings.get.returns(searchConfig.data); + Services.search.wrappedJSObject.reset(); + await Services.search.init(); + + appPrivateDefault = await Services.search.getDefaultPrivate(); + + Services.search.defaultEngine = appPrivateDefault; + } else { + Services.search.defaultEngine = Services.search.defaultPrivateEngine = + appPrivateDefault; + } // Remove all but the default engine. let visibleEngines = await Services.search.getVisibleEngines(); @@ -310,7 +342,9 @@ add_task( "Should only have one visible engine" ); - SearchUtils.GENERAL_SEARCH_ENGINE_IDS.clear(); + if (!SearchUtils.newSearchConfigEnabled) { + SearchUtils.GENERAL_SEARCH_ENGINE_IDS.clear(); + } const observer = new SearchObserver( [ |