
Pier Angelo Vendrame pushed to branch base-browser-140.3.0esr-15.0-1 at The Tor Project / Applications / Tor Browser Commits: 825dd0b0 by Pier Angelo Vendrame at 2025-09-23T14:15:22+02:00 fixup! BB 43525: Skip Remote Settings for search engine customization. BB 44153: Add tests. - - - - - 53431beb by Pier Angelo Vendrame at 2025-09-23T14:15:36+02:00 fixup! BB 40925: Implemented the Security Level component BB 44153: Add search engine customization tests. - - - - - f9f42b6d by Pier Angelo Vendrame at 2025-09-23T14:15:48+02:00 fixup! BB 31740: Remove some unnecessary RemoteSettings instances BB 44153: Add search engine customization tests. Change where we ignore upstream's block lists as the previous mechanism made tests timeout. - - - - - 4 changed files: - toolkit/components/search/SearchService.sys.mjs - + toolkit/components/search/tests/xpcshell/test_base_browser.js - + toolkit/components/search/tests/xpcshell/test_security_level.js - toolkit/components/search/tests/xpcshell/xpcshell.toml Changes: ===================================== toolkit/components/search/SearchService.sys.mjs ===================================== @@ -4,6 +4,7 @@ /* eslint no-shadow: error, mozilla/no-aArgs: error */ +import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs"; import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; const lazy = {}; @@ -1426,6 +1427,10 @@ export class SearchService { // start listening straight away. Services.obs.addObserver(this, lazy.Region.REGION_TOPIC); + this.#getIgnoreListAndSubscribe().catch(ex => + console.error(ex, "Search Service could not get the ignore list.") + ); + this.#engineSelector = new lazy.SearchEngineSelector( this.#handleConfigurationUpdated.bind(this) ); @@ -1568,7 +1573,6 @@ export class SearchService { * handled via a sync listener. * */ - // eslint-disable-next-line no-unused-private-class-members async #getIgnoreListAndSubscribe() { let listener = this.#handleIgnoreListUpdated.bind(this); const current = await lazy.IgnoreLists.getAndSubscribe(listener); @@ -1593,6 +1597,10 @@ export class SearchService { * The event in the format received from RemoteSettings. */ async #handleIgnoreListUpdated(eventData) { + if (AppConstants.BASE_BROWSER_VERSION) { + return; + } + lazy.logConsole.debug("#handleIgnoreListUpdated"); const { data: { current }, ===================================== toolkit/components/search/tests/xpcshell/test_base_browser.js ===================================== @@ -0,0 +1,47 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * This tests the SearchService to check our override of the remote settings is + * working as expected. + */ + +"use strict"; + +const expectedURLs = { + ddg: "https://duckduckgo.com/?q=test", + startpage: "https://www.startpage.com/sp/search?q=test", +}; +const defaultEngine = "ddg"; + +add_setup(async function setup() { + await Services.search.init(); +}); + +add_task(async function test_listEngines() { + const { engines } = + await Services.search.wrappedJSObject._fetchEngineSelectorEngines(); + const foundIdentifiers = engines.map(e => e.identifier); + Assert.deepEqual(foundIdentifiers, Object.keys(expectedURLs)); +}); + +add_task(async function test_default() { + Assert.equal( + (await Services.search.getDefault()).id, + defaultEngine, + `${defaultEngine} is our default search engine in normal mode.` + ); + Assert.equal( + (await Services.search.getDefaultPrivate()).id, + defaultEngine, + `${defaultEngine} is our default search engine in PBM.` + ); +}); + +add_task(function test_checkSearchURLs() { + for (const [id, url] of Object.entries(expectedURLs)) { + const engine = Services.search.getEngineById(id); + const foundUrl = engine.getSubmission("test").uri.spec; + Assert.equal(foundUrl, url, `The URL of ${engine.name} is not altered.`); + } +}); ===================================== toolkit/components/search/tests/xpcshell/test_security_level.js ===================================== @@ -0,0 +1,22 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * This tests that we use the HTML version of DuckDuckGo when in the safest + * security level. + */ + +"use strict"; + +const expectedURLs = { + ddg: "https://html.duckduckgo.com/html?q=test", +}; + +add_task(async function test_securityLevel() { + await Services.search.init(); + for (const [id, url] of Object.entries(expectedURLs)) { + const engine = Services.search.getEngineById(id); + const foundUrl = engine.getSubmission("test").uri.spec; + Assert.equal(foundUrl, url, `${engine.name} is in HTML mode.`); + } +}); ===================================== toolkit/components/search/tests/xpcshell/xpcshell.toml ===================================== @@ -38,6 +38,8 @@ tags = "remote-settings" ["test_async.js"] +["test_base_browser.js"] + ["test_configExpansion.js"] support-files = [ "../../schema/search-config-v2-schema.json", @@ -199,6 +201,9 @@ support-files = [ ["test_searchUrlDomain.js"] +["test_security_level.js"] +prefs = ["browser.security_level.security_slider=1"] + ["test_selectedEngine.js"] ["test_sendSubmissionURL.js"] View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/8893f4a... -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/8893f4a... You're receiving this email because of your account on gitlab.torproject.org.
participants (1)
-
Pier Angelo Vendrame (@pierov)