tor-browser

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

commit 046678d6f69fe960345289d70a50ea99f232b595
parent 2ac07f435839ad86573fa2d8a14547215433cf55
Author: Mark Banner <standard8@mozilla.com>
Date:   Fri, 12 Dec 2025 09:37:33 +0000

Bug 2005550 - Remove browser_*behavior tests. r=search-reviewers,scunnane

The functionality of using different values for different access points has now been removed,
and the search actions are covered by other existing tests.

Differential Revision: https://phabricator.services.mozilla.com/D276012

Diffstat:
Mbrowser/components/search/moz.build | 1-
Mbrowser/components/search/test/browser/browser.toml | 4----
Dbrowser/components/search/test/browser/browser_google_behavior.js | 224-------------------------------------------------------------------------------
Dbrowser/components/search/test/browser/browser_searchEngine_behaviors.js | 220-------------------------------------------------------------------------------
Dbrowser/components/search/test/browser/google_codes/browser.toml | 4----
5 files changed, 0 insertions(+), 453 deletions(-)

diff --git a/browser/components/search/moz.build b/browser/components/search/moz.build @@ -15,7 +15,6 @@ MOZ_SRC_FILES += [ BROWSER_CHROME_MANIFESTS += [ "test/browser/browser.toml", - "test/browser/google_codes/browser.toml", "test/browser/telemetry/browser.toml", ] diff --git a/browser/components/search/test/browser/browser.toml b/browser/components/search/test/browser/browser.toml @@ -79,8 +79,6 @@ skip-if = [ ["browser_displayNotification.js"] -["browser_google_behavior.js"] - ["browser_hiddenOneOffs_diacritics.js"] ["browser_ime_composition.js"] @@ -100,8 +98,6 @@ skip-if = [ ["browser_rich_suggestions.js"] support-files = ["trendingSuggestionEngine.sjs"] -["browser_searchEngine_behaviors.js"] - ["browser_searchPanelHeader.js"] ["browser_search_annotation.js"] diff --git a/browser/components/search/test/browser/browser_google_behavior.js b/browser/components/search/test/browser/browser_google_behavior.js @@ -1,224 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -/* - * Test Google search plugin URLs - * TODO: This test is a near duplicate of browser_searchEngine_behaviors.js but - * specific to Google. This is required due to bug 1315953. - * - * Note: Although we have tests for codes in - * toolkit/components/tests/xpcshell/searchconfigs, we also need this test as an - * integration test to check the search service to selector integration is - * working correctly (especially the ESR codes). - */ - -"use strict"; - -let searchEngineDetails = [ - { - alias: "g", - codes: { - context: "", - keyword: "", - newTab: "", - submission: "", - }, - name: "Google", - }, -]; - -let region = Services.prefs.getCharPref("browser.search.region"); -let code = ""; -switch (region) { - case "US": - if (SearchUtils.MODIFIED_APP_CHANNEL == "esr") { - code = "firefox-b-1-e"; - } else { - code = "firefox-b-1-d"; - } - break; - case "DE": - if (SearchUtils.MODIFIED_APP_CHANNEL == "esr") { - code = "firefox-b-e"; - } else { - code = "firefox-b-d"; - } - break; -} - -if (code) { - let codes = searchEngineDetails[0].codes; - codes.context = code; - codes.newTab = code; - codes.submission = code; - codes.keyword = code; -} - -function promiseContentSearchReady(browser) { - return SpecialPowers.spawn(browser, [], async function () { - return new Promise(resolve => { - SpecialPowers.pushPrefEnv({ - set: [ - [ - "browser.newtabpage.activity-stream.improvesearch.handoffToAwesomebar", - false, - ], - ], - }); - if (content.wrappedJSObject.gContentSearchController) { - let searchController = content.wrappedJSObject.gContentSearchController; - if (searchController.defaultEngine) { - resolve(); - } - } - - content.addEventListener( - "ContentSearchService", - function listener(aEvent) { - if (aEvent.detail.type == "State") { - content.removeEventListener("ContentSearchService", listener); - resolve(); - } - } - ); - }); - }); -} - -add_setup(async function () { - await Services.search.init(); - registerCleanupFunction(() => { - gCUITestUtils.removeSearchBar(); - Services.prefs.clearUserPref("browser.search.widget.lastUsed"); - }); -}); - -for (let engine of searchEngineDetails) { - add_task(async function () { - let previouslySelectedEngine = Services.search.defaultEngine; - await testSearchEngine(engine); - await Services.search.setDefault( - previouslySelectedEngine, - Ci.nsISearchService.CHANGE_REASON_UNKNOWN - ); - }); -} - -async function testSearchEngine(engineDetails) { - let engine = Services.search.getEngineByName(engineDetails.name); - Assert.ok(engine, `${engineDetails.name} is installed`); - - await Services.search.setDefault( - engine, - Ci.nsISearchService.CHANGE_REASON_UNKNOWN - ); - engine.alias = engineDetails.alias; - - // Test search URLs (including purposes). - let url = engine.getSubmission("foo").uri.spec; - let urlParams = new URLSearchParams(url.split("?")[1]); - Assert.equal(urlParams.get("q"), "foo", "Check search URL for 'foo'"); - - let engineTests = [ - { - name: "context menu search", - code: engineDetails.codes.context, - run() { - // Simulate a contextmenu search - // FIXME: This is a bit "low-level"... - SearchUIUtils._loadSearch({ - window, - searchText: "foo", - usePrivate: false, - triggeringPrincipal: - Services.scriptSecurityManager.getSystemPrincipal(), - }); - }, - }, - { - name: "keyword search", - code: engineDetails.codes.keyword, - run() { - gURLBar.value = "? foo"; - gURLBar.focus(); - EventUtils.synthesizeKey("KEY_Enter"); - }, - }, - { - name: "keyword search with alias", - code: engineDetails.codes.keyword, - run() { - gURLBar.value = `${engineDetails.alias} foo`; - gURLBar.focus(); - EventUtils.synthesizeKey("KEY_Enter"); - }, - }, - { - name: "search bar search", - code: engineDetails.codes.submission, - async preTest() { - await gCUITestUtils.addSearchBar(); - }, - run() { - let sb = document.getElementById("searchbar"); - sb.focus(); - sb.value = "foo"; - EventUtils.synthesizeKey("KEY_Enter"); - }, - postTest() { - document.getElementById("searchbar").value = ""; - gCUITestUtils.removeSearchBar(); - }, - }, - { - name: "new tab search", - code: engineDetails.codes.newTab, - async preTest(tab) { - let browser = tab.linkedBrowser; - BrowserTestUtils.startLoadingURIString(browser, "about:newtab"); - await BrowserTestUtils.browserLoaded(browser, false, "about:newtab"); - - await promiseContentSearchReady(browser); - }, - async run(tab) { - await SpecialPowers.spawn(tab.linkedBrowser, [], async function () { - let input = content.document.querySelector("input[id*=search-]"); - input.focus(); - input.value = "foo"; - }); - EventUtils.synthesizeKey("KEY_Enter"); - }, - }, - ]; - - let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser); - - for (let test of engineTests) { - info(`Running: ${test.name}`); - - if (test.preTest) { - await test.preTest(tab); - } - - let googleUrl = "https://www.google.com/search?client=" + test.code; - if (SearchUtils.MODIFIED_APP_CHANNEL == "esr") { - googleUrl += "&channel=entpr"; - } - googleUrl += "&q=foo"; - let promises = [ - BrowserTestUtils.waitForDocLoadAndStopIt(googleUrl, tab), - BrowserTestUtils.browserStopped(tab.linkedBrowser, googleUrl, true), - ]; - - await test.run(tab); - - await Promise.all(promises); - - if (test.postTest) { - await test.postTest(tab); - } - } - - engine.alias = undefined; - BrowserTestUtils.removeTab(tab); -} diff --git a/browser/components/search/test/browser/browser_searchEngine_behaviors.js b/browser/components/search/test/browser/browser_searchEngine_behaviors.js @@ -1,220 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -/* - * Test search plugin URLs - */ - -"use strict"; - -const SEARCH_ENGINE_DETAILS = [ - { - alias: "a", - baseURL: - "https://www.amazon.com/s?tag=admarketus-20&ref=pd_sl_a71c226e8a96bfdb7ae5bc6d1f30e9e88d9e4e3436d7bfb941a95d0a&mfadid=adm&k=foo", - codes: { - context: "", - keyword: "", - newTab: "", - submission: "", - }, - name: "Amazon.com", - }, - { - alias: "b", - baseURL: `https://www.bing.com/search?pc=${ - SearchUtils.MODIFIED_APP_CHANNEL == "esr" ? "MOZR" : "MOZI" - }&{code}q=foo`, - codes: { - context: "form=MOZLBR&", - keyword: "form=MOZLBR&", - newTab: "form=MOZLBR&", - submission: "form=MOZLBR&", - }, - name: "Bing", - }, - { - alias: "d", - baseURL: `https://duckduckgo.com/?{code}t=${ - SearchUtils.MODIFIED_APP_CHANNEL == "esr" ? "ftsa" : "ffab" - }&q=foo`, - codes: { - context: "", - keyword: "", - newTab: "", - submission: "", - }, - name: "DuckDuckGo", - }, - { - alias: "e", - baseURL: - "https://www.ebay.com/sch/?toolid=20004&campid=5338192028&mkevt=1&mkcid=1&mkrid=711-53200-19255-0&kw=foo", - codes: { - context: "", - keyword: "", - newTab: "", - submission: "", - }, - name: "eBay", - }, - // { - // TODO: Google is tested in browser_google_behaviors.js - we can't test it here - // yet because of bug 1315953. - // alias: "g", - // baseURL: "https://www.google.com/search?q=foo&ie=utf-8&oe=utf-8", - // codes: { - // context: "", - // keyword: "", - // newTab: "", - // submission: "", - // }, - // name: "Google", - // }, -]; - -function promiseContentSearchReady(browser) { - return SpecialPowers.spawn(browser, [], async function () { - SpecialPowers.pushPrefEnv({ - set: [ - [ - "browser.newtabpage.activity-stream.improvesearch.handoffToAwesomebar", - false, - ], - ], - }); - await ContentTaskUtils.waitForCondition( - () => - content.wrappedJSObject.gContentSearchController && - content.wrappedJSObject.gContentSearchController.defaultEngine - ); - }); -} - -add_setup(async function () { - await gCUITestUtils.addSearchBar(); - registerCleanupFunction(() => { - gCUITestUtils.removeSearchBar(); - Services.prefs.clearUserPref("browser.search.widget.lastUsed"); - }); -}); - -for (let engine of SEARCH_ENGINE_DETAILS) { - add_task(async function () { - let previouslySelectedEngine = await Services.search.getDefault(); - await testSearchEngine(engine); - await Services.search.setDefault( - previouslySelectedEngine, - Ci.nsISearchService.CHANGE_REASON_UNKNOWN - ); - }); -} - -async function testSearchEngine(engineDetails) { - let engine = Services.search.getEngineByName(engineDetails.name); - Assert.ok(engine, `${engineDetails.name} is installed`); - - await Services.search.setDefault( - engine, - Ci.nsISearchService.CHANGE_REASON_UNKNOWN - ); - engine.alias = engineDetails.alias; - - let base = engineDetails.baseURL; - - // Test search URLs (including purposes). - let url = engine.getSubmission("foo").uri.spec; - Assert.equal( - url, - base.replace("{code}", engineDetails.codes.submission), - "Check search URL for 'foo'" - ); - let sb = document.getElementById("searchbar"); - - let engineTests = [ - { - name: "context menu search", - searchURL: base.replace("{code}", engineDetails.codes.context), - run() { - // Simulate a contextmenu search - // FIXME: This is a bit "low-level"... - SearchUIUtils._loadSearch({ - window, - searchText: "foo", - usePrivate: false, - triggeringPrincipal: - Services.scriptSecurityManager.getSystemPrincipal(), - }); - }, - }, - { - name: "keyword search", - searchURL: base.replace("{code}", engineDetails.codes.keyword), - run() { - gURLBar.value = "? foo"; - gURLBar.focus(); - EventUtils.synthesizeKey("KEY_Enter"); - }, - }, - { - name: "keyword search with alias", - searchURL: base.replace("{code}", engineDetails.codes.keyword), - run() { - gURLBar.value = `${engineDetails.alias} foo`; - gURLBar.focus(); - EventUtils.synthesizeKey("KEY_Enter"); - }, - }, - { - name: "search bar search", - searchURL: base.replace("{code}", engineDetails.codes.submission), - run() { - sb.focus(); - sb.value = "foo"; - EventUtils.synthesizeKey("KEY_Enter"); - }, - }, - { - name: "new tab search", - searchURL: base.replace("{code}", engineDetails.codes.newTab), - async preTest(tab) { - let browser = tab.linkedBrowser; - BrowserTestUtils.startLoadingURIString(browser, "about:newtab"); - - await BrowserTestUtils.browserLoaded(browser, false, "about:newtab"); - await promiseContentSearchReady(browser); - }, - async run(tab) { - await SpecialPowers.spawn(tab.linkedBrowser, [], async function () { - let input = content.document.querySelector("input[id*=search-]"); - input.focus(); - input.value = "foo"; - }); - EventUtils.synthesizeKey("KEY_Enter"); - }, - }, - ]; - - let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser); - - for (let test of engineTests) { - info(`Running: ${test.name}`); - - if (test.preTest) { - await test.preTest(tab); - } - - let promises = [ - BrowserTestUtils.waitForDocLoadAndStopIt(test.searchURL, tab), - BrowserTestUtils.browserStopped(tab.linkedBrowser, test.searchURL, true), - ]; - - await test.run(tab); - - await Promise.all(promises); - } - - engine.alias = undefined; - sb.value = ""; - BrowserTestUtils.removeTab(tab); -} diff --git a/browser/components/search/test/browser/google_codes/browser.toml b/browser/components/search/test/browser/google_codes/browser.toml @@ -1,4 +0,0 @@ -[DEFAULT] -prefs = ["browser.search.region='DE'"] - -["../browser_google_behavior.js"]