tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit c173299a7684d6ae937f895d55b014523d067c64
parent a877d980789fe39f048d4117cbcb4d5233e5d9f2
Author: Cosmin Sabou <csabou@mozilla.com>
Date:   Fri, 14 Nov 2025 18:48:53 +0200

Revert "Bug 1998930 - Don't show contextual search for default search engine. r=urlbar-reviewers,Standard8" for failures on browser_glean_telemetry_bounce

This reverts commit c550000d83525bfe61795bd2c26e2fc901223b60.

Diffstat:
Mbrowser/components/urlbar/ActionsProviderContextualSearch.sys.mjs | 11++---------
Mbrowser/components/urlbar/tests/browser/browser_contextualsearch.js | 61+++++++++++++++++++++++++++----------------------------------
2 files changed, 29 insertions(+), 43 deletions(-)

diff --git a/browser/components/urlbar/ActionsProviderContextualSearch.sys.mjs b/browser/components/urlbar/ActionsProviderContextualSearch.sys.mjs @@ -123,11 +123,6 @@ class ProviderContextualSearch extends ActionsProvider { return engine; } - // Don't match the default engine for non-query-matches. - let defaultEngine = queryContext.isPrivate - ? Services.search.defaultPrivateEngine - : Services.search.defaultEngine; - let browser = lazy.BrowserWindowTracker.getTopWindow()?.gBrowser.selectedBrowser; if (!browser) { @@ -165,12 +160,12 @@ class ProviderContextualSearch extends ActionsProvider { // Cache the result against this host so we do not need to rerun // the same query every keystroke. this.#hostEngines.set(host, hostEngine); - if (hostEngine && hostEngine.engine.name != defaultEngine.name) { + if (hostEngine) { return hostEngine; } } else if (host) { let cachedEngine = this.#hostEngines.get(host); - if (cachedEngine && cachedEngine.engine.name != defaultEngine.name) { + if (cachedEngine) { return cachedEngine; } } @@ -178,8 +173,6 @@ class ProviderContextualSearch extends ActionsProvider { // Lastly match any openSearch if (browser) { let openSearchEngines = lazy.OpenSearchManager.getEngines(browser); - // We don't need to check if the engine has the same name as the - // default engine because OpenSearchManager already handles that. if (openSearchEngines.length) { return { type: OPEN_SEARCH_ENGINE, engine: openSearchEngines[0] }; } diff --git a/browser/components/urlbar/tests/browser/browser_contextualsearch.js b/browser/components/urlbar/tests/browser/browser_contextualsearch.js @@ -51,6 +51,13 @@ let loadUri = async uri => { await loaded; }; +let updateConfig = async config => { + await waitForIdle(); + await SearchTestUtils.setRemoteSettingsConfig(config); + await Services.search.wrappedJSObject.reset(); + await Services.search.init(); +}; + add_setup(async function setup() { await SpecialPowers.pushPrefEnv({ set: [ @@ -60,6 +67,8 @@ add_setup(async function setup() { }); registerCleanupFunction(async () => { + await updateConfig(null); + Services.search.restoreDefaultEngines(); Services.prefs.clearUserPref( "browser.urlbar.quickactions.timesShownOnboardingLabel" ); @@ -86,7 +95,7 @@ add_task(async function test_engine_match() { PlacesTestUtils.waitForNotification("history-cleared"); await PlacesUtils.history.clear(); await promiseClearHistory; - await SearchTestUtils.updateRemoteSettingsConfig(CONFIG); + await updateConfig(CONFIG); await loadUri("https://example.org/"); await UrlbarTestUtils.promiseAutocompleteResultPopup({ @@ -126,10 +135,12 @@ add_task(async function test_engine_match() { EventUtils.synthesizeKey("KEY_Enter"); await onLoad; + await updateConfig(null); }); add_task(async function test_actions() { let testActionCalled = 0; + await updateConfig(CONFIG); await loadUri("https://example.net/"); ActionsProviderQuickActions.addAction("testaction", { @@ -150,6 +161,7 @@ add_task(async function test_actions() { Assert.equal(testActionCalled, 1, "Test action was called"); + await updateConfig(null); ActionsProviderQuickActions.removeAction("testaction"); }); @@ -228,7 +240,7 @@ add_task(async function test_tab_to_search_engine() { }, }, ]); - await SearchTestUtils.updateRemoteSettingsConfig(newConfig); + await updateConfig(newConfig); await UrlbarTestUtils.promiseAutocompleteResultPopup({ window, @@ -255,46 +267,19 @@ add_task(async function test_tab_to_search_engine() { }); await onLoad; - await SearchTestUtils.updateRemoteSettingsConfig(CONFIG); + await updateConfig(null); }); -add_task(async function test_dont_suggest_default_engine() { - await UrlbarTestUtils.promiseAutocompleteResultPopup({ - window, - value: "default", - }); - - Assert.ok( - await hasActions(1), - "Default engine is suggested when it matches the query" - ); - - // Load a URI from the host of the default engine. - await loadUri("https://example.com/"); - - await UrlbarTestUtils.promiseAutocompleteResultPopup({ - window, - value: "something", - }); - - Assert.ok( - !(await hasActions(1)), - "Default engine is not suggested based on current host" - ); - - await UrlbarTestUtils.promisePopupClose(window, () => { - EventUtils.synthesizeKey("KEY_Escape"); - }); -}); - -add_task(async function test_onboarding() { +add_task(async function test_onboarding_default_engine() { await SpecialPowers.pushPrefEnv({ set: [["browser.urlbar.quickactions.timesToShowOnboardingLabel", 3]], }); + await updateConfig(CONFIG); + await UrlbarTestUtils.promiseAutocompleteResultPopup({ window, - value: "non-default", + value: "default", }); Assert.ok( @@ -307,6 +292,8 @@ add_task(async function test_onboarding() { await UrlbarTestUtils.promisePopupClose(window, () => { EventUtils.synthesizeKey("KEY_Escape"); }); + + await updateConfig(null); }); async function hasActions(index) { @@ -317,3 +304,9 @@ async function hasActions(index) { .result; return result.providerName == "UrlbarProviderGlobalActions"; } + +async function waitForIdle() { + for (let i = 0; i < 10; i++) { + await new Promise(resolve => Services.tm.idleDispatchToMainThread(resolve)); + } +}