tor-browser

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

commit dafe5b51f3cf0265b5fdf186ce632a66775f58ac
parent 60cb4824d57267f5b7f18543ab356ae56a672aae
Author: Emma Zuehlcke <emz@mozilla.com>
Date:   Thu, 18 Dec 2025 17:00:38 +0000

Bug 2004729 - In the new preferences design show a confirmation dialog if the baseline exception list checkbox gets unchecked. r=hjones

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

Diffstat:
Mbrowser/components/preferences/privacy.js | 52+++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 39 insertions(+), 13 deletions(-)

diff --git a/browser/components/preferences/privacy.js b/browser/components/preferences/privacy.js @@ -2872,6 +2872,9 @@ Preferences.addSetting({ visible({ contentBlockingCategory }) { return contentBlockingCategory.value == "strict"; }, + onUserChange(value, _deps, setting) { + gPrivacyPane.onBaselineAllowListSettingChange(value, setting); + }, }); Preferences.addSetting({ @@ -2965,6 +2968,9 @@ Preferences.addSetting({ Preferences.addSetting({ id: "etpAllowListBaselineEnabledCustom", pref: "privacy.trackingprotection.allow_list.baseline.enabled", + onUserChange(value, _deps, setting) { + gPrivacyPane.onBaselineAllowListSettingChange(value, setting); + }, }); Preferences.addSetting({ @@ -5553,6 +5559,38 @@ var gPrivacyPane = { return; } + const confirmed = await this._confirmBaselineAllowListDisable(); + + if (confirmed) { + // User confirmed, set the checkbox to false. + event.target.checked = false; + this.maybeNotifyUserToReload(); + } else { + // User cancelled, set the checkbox and the baseline pref to true. + event.target.checked = true; + Services.prefs.setBoolPref( + "privacy.trackingprotection.allow_list.baseline.enabled", + true + ); + } + }, + + async onBaselineAllowListSettingChange(value, setting) { + if (value) { + this.maybeNotifyUserToReload(); + return; + } + + const confirmed = await this._confirmBaselineAllowListDisable(); + if (confirmed) { + this.maybeNotifyUserToReload(); + return; + } + + setting.value = true; + }, + + async _confirmBaselineAllowListDisable() { let [title, body, okButtonText, cancelButtonText] = await document.l10n.formatValues([ { id: "content-blocking-baseline-uncheck-warning-dialog-title" }, @@ -5585,18 +5623,6 @@ var gPrivacyPane = { ); const propertyBag = result.QueryInterface(Ci.nsIPropertyBag2); - - if (propertyBag.get("buttonNumClicked") == 1) { - // User confirmed, set the checkbox to false. - event.target.checked = false; - this.maybeNotifyUserToReload(); - } else { - // User cancelled, set the checkbox and the baseline pref to true. - event.target.checked = true; - Services.prefs.setBoolPref( - "privacy.trackingprotection.allow_list.baseline.enabled", - true - ); - } + return propertyBag.get("buttonNumClicked") == 1; }, };