
henry pushed to branch tor-browser-140.0esr-15.0-1 at The Tor Project / Applications / Tor Browser Commits: da315c55 by Henry Wilkes at 2025-07-16T18:30:55+01:00 fixup! TB 40597: Implement TorSettings module TB 43766: Save TorSettings to preferences in separate groups. - - - - - bfe6d078 by Henry Wilkes at 2025-07-16T18:30:56+01:00 fixup! TB 40597: Implement TorSettings module TB 43766: Update a FIXME comment to point to a newer issue. - - - - - 3f8590fc by Henry Wilkes at 2025-07-16T18:30:56+01:00 fixup! Lox integration TB 43765: Disable lox on alpha channel. - - - - - 2 changed files: - toolkit/components/lox/Lox.sys.mjs - toolkit/modules/TorSettings.sys.mjs Changes: ===================================== toolkit/components/lox/Lox.sys.mjs ===================================== @@ -1,5 +1,4 @@ /* eslint-disable mozilla/valid-lazy */ -import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs"; import { clearInterval, setInterval, @@ -121,7 +120,7 @@ class LoxImpl { * * @type {boolean} */ - #enabled = AppConstants.MOZ_UPDATE_CHANNEL !== "release"; + #enabled = false; get enabled() { return this.#enabled; ===================================== toolkit/modules/TorSettings.sys.mjs ===================================== @@ -612,8 +612,7 @@ class TorSettingsImpl { this.#settings.bridges.source === TorBridgeSource.Lox ) { // Re-trigger the call to lazy.Lox.getBridges. - // FIXME: This can compete with TorConnect to reach TorProvider. - // tor-browser#42316 + // FIXME: This can cancel a bootstrap. tor-browser#43991. this.changeSettings({ bridges: { source: TorBridgeSource.Lox, @@ -767,14 +766,11 @@ class TorSettingsImpl { } /** - * Save our settings to prefs. + * Save our bridge settings. */ - #saveToPrefs() { - lazy.logger.debug("saveToPrefs()"); + #saveBridgeSettings() { + lazy.logger.debug("Saving bridge settings"); - this.#checkIfInitialized(); - - /* Bridges */ Services.prefs.setBoolPref( TorSettingsPrefs.bridges.enabled, this.#settings.bridges.enabled @@ -812,7 +808,14 @@ class TorSettingsImpl { ); }); } - /* Proxy */ + } + + /** + * Save our proxy settings. + */ + #saveProxySettings() { + lazy.logger.debug("Saving proxy settings"); + Services.prefs.setBoolPref( TorSettingsPrefs.proxy.enabled, this.#settings.proxy.enabled @@ -845,7 +848,14 @@ class TorSettingsImpl { Services.prefs.clearUserPref(TorSettingsPrefs.proxy.username); Services.prefs.clearUserPref(TorSettingsPrefs.proxy.password); } - /* Firewall */ + } + + /** + * Save our firewall settings. + */ + #saveFirewallSettings() { + lazy.logger.debug("Saving firewall settings"); + Services.prefs.setBoolPref( TorSettingsPrefs.firewall.enabled, this.#settings.firewall.enabled @@ -1403,7 +1413,32 @@ class TorSettingsImpl { // No errors so far, so save and commit. this.#settings = completeSettings; - this.#saveToPrefs(); + // NOTE: We want to avoid overwriting saved preference values unless the + // user actually makes a change in their settings. + // In particular, if we fail to load a setting at startup due to a bug, the + // #settings object for that group will point to the #defaultSettings value + // instead. We do not want to write these #defaultSettings to the user's + // settings unless the user actually makes a change in one of the groups. + // E.g. we do not want a change in the proxy settings to overwrite the + // saved bridge settings. Hence, we only save the groups that have changes. + // See tor-browser#43766. + // NOTE: We could go more fine-grained and only save the preference values + // that actually change. E.g. only save the bridges.enabled pref when the + // user switches the toggle, and leave the bridges.bridge_strings as they + // are. However, at the time of implementation there is no known benefit to + // doing this, since the #defaultSettings will not allow for any changes + // that don't require changing the group entirely. E.g. to change + // bridges.enabled when starting with the #defaultSettings.bridges, + // bridges.bridge_strings must necessarily be set. + if (apply.bridges) { + this.#saveBridgeSettings(); + } + if (apply.proxy) { + this.#saveProxySettings(); + } + if (apply.firewall) { + this.#saveFirewallSettings(); + } if (changes.length) { Services.obs.notifyObservers( View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/0a4f89e... -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/0a4f89e... You're receiving this email because of your account on gitlab.torproject.org.