diff options
Diffstat (limited to 'browser/components/urlbar/tests/browser/browser_recentsearches.js')
-rw-r--r-- | browser/components/urlbar/tests/browser/browser_recentsearches.js | 94 |
1 files changed, 93 insertions, 1 deletions
diff --git a/browser/components/urlbar/tests/browser/browser_recentsearches.js b/browser/components/urlbar/tests/browser/browser_recentsearches.js index e0ba5f684f..d2b91a3a53 100644 --- a/browser/components/urlbar/tests/browser/browser_recentsearches.js +++ b/browser/components/urlbar/tests/browser/browser_recentsearches.js @@ -6,10 +6,51 @@ const CONFIG_DEFAULT = [ { webExtension: { id: "basic@search.mozilla.org" }, appliesTo: [{ included: { everywhere: true } }], + urls: { + trending: { + fullPath: + "https://example.com/browser/browser/components/search/test/browser/trendingSuggestionEngine.sjs", + query: "", + }, + }, default: "yes", }, ]; +const CONFIG_DEFAULT_V2 = [ + { + recordType: "engine", + identifier: "basic", + base: { + name: "basic", + urls: { + search: { + base: "https://example.com", + searchTermParamName: "q", + }, + trending: { + base: "https://example.com/browser/browser/components/search/test/browser/trendingSuggestionEngine.sjs", + method: "GET", + }, + }, + }, + variants: [ + { + environment: { allRegionsAndLocales: true }, + }, + ], + }, + { + recordType: "defaultEngines", + globalDefault: "basic", + specificDefaults: [], + }, + { + recordType: "engineOrders", + orders: [], + }, +]; + const TOP_SITES = [ "https://example-1.com/", "https://example-2.com/", @@ -38,7 +79,9 @@ add_setup(async () => { }); SearchTestUtils.useMockIdleService(); - await SearchTestUtils.updateRemoteSettingsConfig(CONFIG_DEFAULT); + await SearchTestUtils.updateRemoteSettingsConfig( + SearchUtils.newSearchConfigEnabled ? CONFIG_DEFAULT_V2 : CONFIG_DEFAULT + ); Services.telemetry.clearScalars(); registerCleanupFunction(async () => { @@ -135,4 +178,53 @@ add_task(async () => { Assert.equal(result.providerName, "RecentSearches"); await BrowserTestUtils.removeTab(tab); + await SpecialPowers.popPrefEnv(); +}); + +// Test that triggering the help menu of trending suggestions does not +// record that selection as a search. +add_task(async () => { + await UrlbarTestUtils.formHistory.clear(); + await SpecialPowers.pushPrefEnv({ + set: [ + ["browser.urlbar.suggest.topsites", false], + ["browser.urlbar.suggest.trending", true], + ["browser.urlbar.trending.featureGate", true], + ["browser.urlbar.trending.requireSearchMode", false], + ["app.support.baseURL", "https://example.com"], + ], + }); + + let tab = await BrowserTestUtils.openNewForegroundTab( + window.gBrowser, + "data:text/html," + ); + + info("Open the urlbar and pick the help menu of a trending result."); + await UrlbarTestUtils.promiseAutocompleteResultPopup({ + window, + value: "", + }); + + await UrlbarTestUtils.openResultMenuAndClickItem(window, "help", { + resultIndex: 1, + openByMouse: true, + }); + + info("Open the urlbar and check that a recent search has not been added."); + await UrlbarTestUtils.promiseAutocompleteResultPopup({ + window, + value: "", + }); + + let { result } = await UrlbarTestUtils.getDetailsOfResultAt(window, 0); + Assert.notEqual( + result.providerName, + "RecentSearches", + "Click on help URL did not record a search" + ); + + await BrowserTestUtils.removeTab(gBrowser.selectedTab); + await BrowserTestUtils.removeTab(tab); + await SpecialPowers.popPrefEnv(); }); |