henry pushed to branch tor-browser-147.0a1-16.0-2 at The Tor Project / Applications / Tor Browser Commits: 63654584 by Henry Wilkes at 2026-02-16T13:02:36+00:00 fixup! BB 43525: Skip Remote Settings for search engine customization. TB 44647: Restore upstream's logic for getConfiguration* methods. - - - - - fbfd9723 by Henry Wilkes at 2026-02-16T13:35:30+00:00 fixup! BB 43525: Skip Remote Settings for search engine customization. TB 44647: Re-implement the search configuration patch in a more minimal form. - - - - - 1 changed file: - toolkit/components/search/SearchEngineSelector.sys.mjs Changes: ===================================== toolkit/components/search/SearchEngineSelector.sys.mjs ===================================== @@ -92,19 +92,44 @@ export class SearchEngineSelector { return this.#getConfigurationPromise; } - let { promise, resolve } = Promise.withResolvers(); - this.#getConfigurationPromise = promise; - this.#configuration = await ( - await fetch( - "chrome://global/content/search/base-browser-search-engines.json" - ) - ).json(); - resolve(this.#configuration); + this.#getConfigurationPromise = Promise.all([ + this.#getConfiguration(), + this.#getConfigurationOverrides(), + ]); + let remoteSettingsData = await this.#getConfigurationPromise; + this.#configuration = remoteSettingsData[0]; + // For Base Browser, we don't expect the configuration to ever change in a + // session, so we keep the #getConfigurationPromise as-is for later calls. + + if (!this.#configuration?.length) { + throw Components.Exception( + "Failed to get engine data from Remote Settings", + Cr.NS_ERROR_UNEXPECTED + ); + } + + /** + * Records whether the listeners have been added or not. + */ + // For Base Browser, we don't use remoteConfig. tor-browser#43525. + if (!AppConstants.BASE_BROWSER_VERSION && !this.#listenerAdded) { + this.#remoteConfig.on("sync", this.#boundOnConfigurationUpdated); + this.#remoteConfigOverrides.on( + "sync", + this.#boundOnConfigurationOverridesUpdated + ); + /** + * Records whether the listeners have been added or not. + */ + this.#listenerAdded = true; + } this.#selector.setSearchConfig( JSON.stringify({ data: this.#configuration }) ); - this.#selector.setConfigOverrides(JSON.stringify({ data: [] })); + this.#selector.setConfigOverrides( + JSON.stringify({ data: remoteSettingsData[1] }) + ); return this.#configuration; } @@ -324,6 +349,15 @@ export class SearchEngineSelector { * could be obtained. */ async #getConfiguration(firstTime = true) { + if (AppConstants.BASE_BROWSER_VERSION) { + // For Base Browser, load the config from a local file, rather than + // #remoteConfig. tor-browser#43525. + return ( + await fetch( + "chrome://global/content/search/base-browser-search-engines.json" + ) + ).json(); + } let result = []; let failed = false; try { @@ -409,6 +443,27 @@ export class SearchEngineSelector { } } + /** + * Obtains the configuration overrides from remote settings. + * + * @returns {Promise<object[]>} + * An array of objects in the database, or an empty array if none + * could be obtained. + */ + async #getConfigurationOverrides() { + if (AppConstants.BASE_BROWSER_VERSION) { + // For Base Browser, we don't want overrides. tor-browser#43525. + return []; + } + let result = []; + try { + result = await this.#remoteConfigOverrides.get(); + } catch (ex) { + // This data is remote only, so we just return an empty array if it fails. + } + return result; + } + /** * @type {InstanceType<typeof lazy.SearchEngineSelector>?} */ View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/bd7cc6e... -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/bd7cc6e... You're receiving this email because of your account on gitlab.torproject.org.
participants (1)
-
henry (@henry)