henry pushed to branch mullvad-browser-147.0a1-16.0-2 at The Tor Project /
Applications / Mullvad Browser
Commits:
a2ea1688 by Henry Wilkes at 2026-02-16T14:25:34+00:00
fixup! BB 43525: Skip Remote Settings for search engine customization.
TB 44647: Restore upstream's logic for getConfiguration* methods.
- - - - -
e64642c4 by Henry Wilkes at 2026-02-16T14:25:35+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/mullvad-browser/-/compare/2cc34d803a653d6bab0394aa4ca4e4d53ad0c9f0...e64642c49de2f34a57c75d477fe46c8b55efb76b
--
View it on GitLab:
https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/compare/2cc34d803a653d6bab0394aa4ca4e4d53ad0c9f0...e64642c49de2f34a57c75d477fe46c8b55efb76b
You're receiving this email because of your account on gitlab.torproject.org.
_______________________________________________
tor-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]