commit 303d6e41229ba17b5401cf21140cf868a114c381
parent 08292d61d3173d205f5dbad8e44e2a242b525d22
Author: Rebecca King <rking@mozilla.com>
Date: Tue, 28 Oct 2025 16:35:23 +0000
Bug 1993052 - Create section for VPN autostart preferences in about:settings - r=ip-protection-reviewers,fluent-reviewers,mstriemer,bolsson,fchasen
Differential Revision: https://phabricator.services.mozilla.com/D270258
Diffstat:
5 files changed, 102 insertions(+), 11 deletions(-)
diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js
@@ -3496,9 +3496,13 @@ pref("browser.contextual-services.contextId.rotation-in-days", 7);
pref("browser.contextual-services.contextId.rust-component.enabled", true);
// Pref to enable the IP protection feature
-pref("browser.ipProtection.autoStartEnabled", false);
pref("browser.ipProtection.enabled", false);
+// Pref to enable IP protection autostart
+pref("browser.ipProtection.autoStartEnabled", false);
+pref("browser.ipProtection.autoStartPrivateEnabled", false);
+// Pref to track whether the user has turned IP protection on
pref("browser.ipProtection.userEnabled", false);
+// Pref to track which experiment version the user is enrolled in
pref("browser.ipProtection.variant", "");
pref("browser.ipProtection.exceptionsMode", "all");
pref("browser.ipProtection.domainExclusions", "");
diff --git a/browser/components/preferences/main.js b/browser/components/preferences/main.js
@@ -1519,6 +1519,23 @@ let SETTINGS_CONFIG = {
},
],
},
+ {
+ id: "ipProtectionAutoStart",
+ l10nId: "ip-protection-autostart",
+ control: "moz-fieldset",
+ items: [
+ {
+ id: "ipProtectionAutoStartCheckbox",
+ l10nId: "ip-protection-autostart-checkbox",
+ control: "moz-checkbox",
+ },
+ {
+ id: "ipProtectionAutoStartPrivateCheckbox",
+ l10nId: "ip-protection-autostart-private-checkbox",
+ control: "moz-checkbox",
+ },
+ ],
+ },
],
},
cookiesAndSiteData: {
diff --git a/browser/components/preferences/privacy.js b/browser/components/preferences/privacy.js
@@ -202,6 +202,8 @@ Preferences.addAll([
// Firefox VPN
{ id: "browser.ipProtection.variant", type: "string" },
{ id: "browser.ipProtection.exceptionsMode", type: "string" },
+ { id: "browser.ipProtection.autoStartEnabled", type: "bool" },
+ { id: "browser.ipProtection.autoStartPrivateEnabled", type: "bool" },
// Media
{ id: "media.autoplay.default", type: "int" },
@@ -1279,6 +1281,23 @@ Preferences.addSetting({
// with gSubDialog.open
},
});
+Preferences.addSetting({
+ id: "ipProtectionAutoStart",
+ deps: ["ipProtectionVisible"],
+ visible: ({ ipProtectionVisible }) => ipProtectionVisible.value,
+});
+Preferences.addSetting({
+ id: "ipProtectionAutoStartCheckbox",
+ pref: "browser.ipProtection.autoStartEnabled",
+ deps: ["ipProtectionVisible", "ipProtectionAutoStart"],
+ visible: ({ ipProtectionVisible }) => ipProtectionVisible.value,
+});
+Preferences.addSetting({
+ id: "ipProtectionAutoStartPrivateCheckbox",
+ pref: "browser.ipProtection.autoStartPrivateEnabled",
+ deps: ["ipProtectionVisible", "ipProtectionAutoStart"],
+ visible: ({ ipProtectionVisible }) => ipProtectionVisible.value,
+});
// Study opt out
if (AppConstants.MOZ_DATA_REPORTING) {
diff --git a/browser/components/preferences/tests/browser_privacy_ipprotection.js b/browser/components/preferences/tests/browser_privacy_ipprotection.js
@@ -7,14 +7,23 @@
const FEATURE_PREF = "browser.ipProtection.variant";
const MODE_PREF = "browser.ipProtection.exceptionsMode";
+const AUTOSTART_PREF = "browser.ipProtection.autoStartEnabled";
+const AUTOSTART_PRIVATE_PREF = "browser.ipProtection.autoStartPrivateEnabled";
const SECTION_ID = "dataIPProtectionGroup";
-async function setupVpnPrefs({ feature, mode = "all" }) {
+async function setupVpnPrefs({
+ feature,
+ mode = "all",
+ autostart = false,
+ autostartprivate = false,
+}) {
return SpecialPowers.pushPrefEnv({
set: [
[FEATURE_PREF, feature],
[MODE_PREF, mode],
+ [AUTOSTART_PREF, autostart],
+ [AUTOSTART_PRIVATE_PREF, autostartprivate],
],
});
}
@@ -48,8 +57,6 @@ add_task(
is_element_visible(section, "#dataIPProtectionGroup is shown");
}
);
-
- await SpecialPowers.popPrefEnv();
}
);
@@ -106,8 +113,6 @@ add_task(async function test_exceptions_load_with_all_mode() {
);
}
);
-
- await SpecialPowers.popPrefEnv();
});
// Test the site exceptions controls load correctly with mode set to "select"
@@ -163,9 +168,6 @@ add_task(async function test_exceptions_with_select_mode() {
);
}
);
-
- await SpecialPowers.popPrefEnv();
- await SpecialPowers.popPrefEnv();
});
// Test the site exceptions controls and pref update correctly after selecting another mode option.
@@ -219,7 +221,49 @@ add_task(async function test_exceptions_change_mode_and_buttons() {
Services.prefs.clearUserPref(MODE_PREF);
}
);
+});
+
+// Test that autostart checkboxes exist and map to the correct preferences
+add_task(async function test_autostart_checkboxes() {
+ await setupVpnPrefs({
+ feature: "beta",
+ autostart: true,
+ autostartprivate: true,
+ });
+
+ await BrowserTestUtils.withNewTab(
+ { gBrowser, url: "about:preferences#privacy" },
+ async function (browser) {
+ let section = browser.contentDocument.getElementById(SECTION_ID);
+ let settingGroup = section.querySelector(
+ `setting-group[groupid="ipprotection"]`
+ );
+ is_element_visible(section, "#dataIPProtectionGroup is shown");
+ is_element_visible(settingGroup, "ipprotection setting group is shown");
+
+ let autoStartSettings = settingGroup?.querySelector(
+ "#ipProtectionAutoStart"
+ );
+ is_element_visible(
+ autoStartSettings,
+ "autoStart settings group is shown"
+ );
- await SpecialPowers.popPrefEnv();
- await SpecialPowers.popPrefEnv();
+ let autoStartCheckbox = autoStartSettings?.querySelector(
+ "#ipProtectionAutoStartCheckbox"
+ );
+ let autoStartPrivateCheckbox = autoStartSettings?.querySelector(
+ "#ipProtectionAutoStartPrivateCheckbox"
+ );
+
+ Assert.ok(
+ autoStartCheckbox.checked,
+ "Autostart checkbox should be checked"
+ );
+ Assert.ok(
+ autoStartPrivateCheckbox.checked,
+ "Autostart in private browsing checkbox should be checked"
+ );
+ }
+ );
});
diff --git a/browser/locales-preview/ipProtection.ftl b/browser/locales-preview/ipProtection.ftl
@@ -90,6 +90,13 @@ ip-protection-site-exceptions-all-sites-button =
.label = { -firefox-vpn-brand-name } is off for these websites
.description = No websites added yet
+ip-protection-autostart =
+ .label = Turn on VPN automatically
+ip-protection-autostart-checkbox =
+ .label = When I open { -brand-short-name }
+ip-protection-autostart-private-checkbox =
+ .label = In private windows
+
# "Select" is an adjective here to describe a setting that allows running the VPN on certain sites only.
# Not to be confused with the action of selecting a site, which is not at all applicable to this setting.
ip-protection-site-exceptions-select-sites-radio =