Skip to content

Commit 303d6e4

Browse files
author
Rebecca King
committed
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
1 parent 08292d6 commit 303d6e4

File tree

5 files changed

+102
-11
lines changed

5 files changed

+102
-11
lines changed

browser/app/profile/firefox.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3496,9 +3496,13 @@ pref("browser.contextual-services.contextId.rotation-in-days", 7);
34963496
pref("browser.contextual-services.contextId.rust-component.enabled", true);
34973497

34983498
// Pref to enable the IP protection feature
3499-
pref("browser.ipProtection.autoStartEnabled", false);
35003499
pref("browser.ipProtection.enabled", false);
3500+
// Pref to enable IP protection autostart
3501+
pref("browser.ipProtection.autoStartEnabled", false);
3502+
pref("browser.ipProtection.autoStartPrivateEnabled", false);
3503+
// Pref to track whether the user has turned IP protection on
35013504
pref("browser.ipProtection.userEnabled", false);
3505+
// Pref to track which experiment version the user is enrolled in
35023506
pref("browser.ipProtection.variant", "");
35033507
pref("browser.ipProtection.exceptionsMode", "all");
35043508
pref("browser.ipProtection.domainExclusions", "");

browser/components/preferences/main.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,23 @@ let SETTINGS_CONFIG = {
15191519
},
15201520
],
15211521
},
1522+
{
1523+
id: "ipProtectionAutoStart",
1524+
l10nId: "ip-protection-autostart",
1525+
control: "moz-fieldset",
1526+
items: [
1527+
{
1528+
id: "ipProtectionAutoStartCheckbox",
1529+
l10nId: "ip-protection-autostart-checkbox",
1530+
control: "moz-checkbox",
1531+
},
1532+
{
1533+
id: "ipProtectionAutoStartPrivateCheckbox",
1534+
l10nId: "ip-protection-autostart-private-checkbox",
1535+
control: "moz-checkbox",
1536+
},
1537+
],
1538+
},
15221539
],
15231540
},
15241541
cookiesAndSiteData: {

browser/components/preferences/privacy.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ Preferences.addAll([
202202
// Firefox VPN
203203
{ id: "browser.ipProtection.variant", type: "string" },
204204
{ id: "browser.ipProtection.exceptionsMode", type: "string" },
205+
{ id: "browser.ipProtection.autoStartEnabled", type: "bool" },
206+
{ id: "browser.ipProtection.autoStartPrivateEnabled", type: "bool" },
205207

206208
// Media
207209
{ id: "media.autoplay.default", type: "int" },
@@ -1279,6 +1281,23 @@ Preferences.addSetting({
12791281
// with gSubDialog.open
12801282
},
12811283
});
1284+
Preferences.addSetting({
1285+
id: "ipProtectionAutoStart",
1286+
deps: ["ipProtectionVisible"],
1287+
visible: ({ ipProtectionVisible }) => ipProtectionVisible.value,
1288+
});
1289+
Preferences.addSetting({
1290+
id: "ipProtectionAutoStartCheckbox",
1291+
pref: "browser.ipProtection.autoStartEnabled",
1292+
deps: ["ipProtectionVisible", "ipProtectionAutoStart"],
1293+
visible: ({ ipProtectionVisible }) => ipProtectionVisible.value,
1294+
});
1295+
Preferences.addSetting({
1296+
id: "ipProtectionAutoStartPrivateCheckbox",
1297+
pref: "browser.ipProtection.autoStartPrivateEnabled",
1298+
deps: ["ipProtectionVisible", "ipProtectionAutoStart"],
1299+
visible: ({ ipProtectionVisible }) => ipProtectionVisible.value,
1300+
});
12821301

12831302
// Study opt out
12841303
if (AppConstants.MOZ_DATA_REPORTING) {

browser/components/preferences/tests/browser_privacy_ipprotection.js

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,23 @@
77

88
const FEATURE_PREF = "browser.ipProtection.variant";
99
const MODE_PREF = "browser.ipProtection.exceptionsMode";
10+
const AUTOSTART_PREF = "browser.ipProtection.autoStartEnabled";
11+
const AUTOSTART_PRIVATE_PREF = "browser.ipProtection.autoStartPrivateEnabled";
1012

1113
const SECTION_ID = "dataIPProtectionGroup";
1214

13-
async function setupVpnPrefs({ feature, mode = "all" }) {
15+
async function setupVpnPrefs({
16+
feature,
17+
mode = "all",
18+
autostart = false,
19+
autostartprivate = false,
20+
}) {
1421
return SpecialPowers.pushPrefEnv({
1522
set: [
1623
[FEATURE_PREF, feature],
1724
[MODE_PREF, mode],
25+
[AUTOSTART_PREF, autostart],
26+
[AUTOSTART_PRIVATE_PREF, autostartprivate],
1827
],
1928
});
2029
}
@@ -48,8 +57,6 @@ add_task(
4857
is_element_visible(section, "#dataIPProtectionGroup is shown");
4958
}
5059
);
51-
52-
await SpecialPowers.popPrefEnv();
5360
}
5461
);
5562

@@ -106,8 +113,6 @@ add_task(async function test_exceptions_load_with_all_mode() {
106113
);
107114
}
108115
);
109-
110-
await SpecialPowers.popPrefEnv();
111116
});
112117

113118
// 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() {
163168
);
164169
}
165170
);
166-
167-
await SpecialPowers.popPrefEnv();
168-
await SpecialPowers.popPrefEnv();
169171
});
170172

171173
// 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() {
219221
Services.prefs.clearUserPref(MODE_PREF);
220222
}
221223
);
224+
});
225+
226+
// Test that autostart checkboxes exist and map to the correct preferences
227+
add_task(async function test_autostart_checkboxes() {
228+
await setupVpnPrefs({
229+
feature: "beta",
230+
autostart: true,
231+
autostartprivate: true,
232+
});
233+
234+
await BrowserTestUtils.withNewTab(
235+
{ gBrowser, url: "about:preferences#privacy" },
236+
async function (browser) {
237+
let section = browser.contentDocument.getElementById(SECTION_ID);
238+
let settingGroup = section.querySelector(
239+
`setting-group[groupid="ipprotection"]`
240+
);
241+
is_element_visible(section, "#dataIPProtectionGroup is shown");
242+
is_element_visible(settingGroup, "ipprotection setting group is shown");
243+
244+
let autoStartSettings = settingGroup?.querySelector(
245+
"#ipProtectionAutoStart"
246+
);
247+
is_element_visible(
248+
autoStartSettings,
249+
"autoStart settings group is shown"
250+
);
222251

223-
await SpecialPowers.popPrefEnv();
224-
await SpecialPowers.popPrefEnv();
252+
let autoStartCheckbox = autoStartSettings?.querySelector(
253+
"#ipProtectionAutoStartCheckbox"
254+
);
255+
let autoStartPrivateCheckbox = autoStartSettings?.querySelector(
256+
"#ipProtectionAutoStartPrivateCheckbox"
257+
);
258+
259+
Assert.ok(
260+
autoStartCheckbox.checked,
261+
"Autostart checkbox should be checked"
262+
);
263+
Assert.ok(
264+
autoStartPrivateCheckbox.checked,
265+
"Autostart in private browsing checkbox should be checked"
266+
);
267+
}
268+
);
225269
});

browser/locales-preview/ipProtection.ftl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ ip-protection-site-exceptions-all-sites-button =
9090
.label = { -firefox-vpn-brand-name } is off for these websites
9191
.description = No websites added yet
9292
93+
ip-protection-autostart =
94+
.label = Turn on VPN automatically
95+
ip-protection-autostart-checkbox =
96+
.label = When I open { -brand-short-name }
97+
ip-protection-autostart-private-checkbox =
98+
.label = In private windows
99+
93100
# "Select" is an adjective here to describe a setting that allows running the VPN on certain sites only.
94101
# Not to be confused with the action of selecting a site, which is not at all applicable to this setting.
95102
ip-protection-site-exceptions-select-sites-radio =

0 commit comments

Comments
 (0)