Skip to content

Commit 7b4f02f

Browse files
committed
Bug 1971212 - Add ETP status card. r=fluent-reviewers,bvandersloot,bolsson,hjones
The advanced view (opened via the "Advanced settings" button) will be implemented in Bug 1971444. Differential Revision: https://phabricator.services.mozilla.com/D273267
1 parent 2451925 commit 7b4f02f

File tree

6 files changed

+214
-1
lines changed

6 files changed

+214
-1
lines changed

browser/components/preferences/main.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2947,6 +2947,39 @@ SettingGroupManager.registerGroups({
29472947
},
29482948
],
29492949
},
2950+
etpStatus: {
2951+
inProgress: true,
2952+
headingLevel: 2,
2953+
l10nId: "preferences-etp-status-header",
2954+
supportPage: "enhanced-tracking-protection",
2955+
iconSrc: "chrome://browser/skin/controlcenter/tracking-protection.svg",
2956+
items: [
2957+
{
2958+
id: "etpStatusBoxGroup",
2959+
control: "moz-box-group",
2960+
items: [
2961+
{
2962+
id: "etpStatusItem",
2963+
l10nId: "preferences-etp-level-standard",
2964+
control: "moz-box-item",
2965+
},
2966+
{
2967+
id: "etpStatusAdvancedButton",
2968+
l10nId: "preferences-etp-status-advanced-button",
2969+
control: "moz-box-button",
2970+
},
2971+
],
2972+
},
2973+
{
2974+
id: "protectionsDashboardLink",
2975+
l10nId: "preferences-etp-status-protections-dashboard-link",
2976+
control: "moz-box-link",
2977+
controlAttrs: {
2978+
href: "about:protections",
2979+
},
2980+
},
2981+
],
2982+
},
29502983
});
29512984

29522985
/**

browser/components/preferences/privacy.inc.xhtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
<html:h1 data-l10n-id="privacy-header"/>
1515
</hbox>
1616

17-
17+
<!-- Enhanced Tracking Protection Status Section -->
18+
<html:setting-group groupid="etpStatus" data-category="panePrivacy" data-subcategory="etpStatus" hidden="true"></html:setting-group>
1819

1920
<!-- Tracking / Content Blocking -->
2021
<groupbox id="trackingGroup" data-category="panePrivacy" hidden="true" aria-describedby="contentBlockingDescription" class="highlighting-group">

browser/components/preferences/privacy.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2801,6 +2801,44 @@ Preferences.addSetting({
28012801
},
28022802
});
28032803

2804+
Preferences.addSetting({
2805+
id: "contentBlockingCategory",
2806+
pref: "browser.contentblocking.category",
2807+
});
2808+
2809+
Preferences.addSetting({
2810+
id: "etpStatusBoxGroup",
2811+
});
2812+
2813+
Preferences.addSetting({
2814+
id: "etpStatusItem",
2815+
deps: ["contentBlockingCategory"],
2816+
getControlConfig(config, { contentBlockingCategory }) {
2817+
// Display a different description and label depending on the content blocking category (= ETP level).
2818+
let categoryToL10nId = {
2819+
standard: "preferences-etp-level-standard",
2820+
strict: "preferences-etp-level-strict",
2821+
custom: "preferences-etp-level-custom",
2822+
};
2823+
2824+
return {
2825+
...config,
2826+
l10nId:
2827+
categoryToL10nId[contentBlockingCategory.value] ??
2828+
"preferences-etp-level-standard",
2829+
};
2830+
},
2831+
});
2832+
2833+
Preferences.addSetting({
2834+
id: "etpStatusAdvancedButton",
2835+
// TODO: Bug 1971444 - Click action to switch to advanced subview.
2836+
});
2837+
2838+
Preferences.addSetting({
2839+
id: "protectionsDashboardLink",
2840+
});
2841+
28042842
function setEventListener(aId, aEventType, aCallback) {
28052843
document
28062844
.getElementById(aId)
@@ -3362,6 +3400,7 @@ var gPrivacyPane = {
33623400
initSettingGroup("permissions");
33633401
initSettingGroup("dnsOverHttps");
33643402
initSettingGroup("dnsOverHttpsAdvanced");
3403+
initSettingGroup("etpStatus");
33653404

33663405
/* Initialize Content Blocking */
33673406
this.initContentBlocking();

browser/components/preferences/tests/browser.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ skip-if = [
107107

108108
["browser_etp_exceptions_dialog.js"]
109109

110+
["browser_etp_status.js"]
111+
110112
["browser_experimental_features.js"]
111113

112114
["browser_experimental_features_filter.js"]
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/* Any copyright is dedicated to the Public Domain.
2+
https://creativecommons.org/publicdomain/zero/1.0/ */
3+
4+
"use strict";
5+
6+
add_setup(async function () {
7+
await SpecialPowers.pushPrefEnv({
8+
set: [
9+
// Show the ETP status section in the privacy pane.
10+
["browser.settings-redesign.etpStatus.enabled", true],
11+
// Ensure we start from ETP "standard".
12+
["browser.contentblocking.category", "standard"],
13+
],
14+
});
15+
});
16+
17+
/**
18+
* Helper for waiting for and asserting the ETP status item state.
19+
* Can be called both when the item already changed or when we need to wait for the change.
20+
*
21+
* @param {Document} doc - The preferences document.
22+
* @param {*} options - The expected ETP status item state.
23+
* @param {string} options.l10nId - The expected l10nId attribute value.
24+
* @param {string} options.description - The expected description attribute value.
25+
*/
26+
async function waitForAndAssertEtpStatusItemState(doc, { l10nId }) {
27+
let etpStatusItem = doc.getElementById("etpStatusItem");
28+
Assert.ok(
29+
BrowserTestUtils.isVisible(etpStatusItem),
30+
"ETP status box item should be visible"
31+
);
32+
33+
let condition = () => {
34+
return etpStatusItem.getAttribute("data-l10n-id") == l10nId;
35+
};
36+
if (!condition()) {
37+
await BrowserTestUtils.waitForMutationCondition(
38+
etpStatusItem,
39+
{ attributes: true, attributeFilter: ["data-l10n-id", "description"] },
40+
condition
41+
);
42+
}
43+
44+
Assert.equal(etpStatusItem.getAttribute("data-l10n-id"), l10nId);
45+
}
46+
47+
// Test that the ETP status section updates correctly when changing the ETP category.
48+
add_task(async function test_status_categories() {
49+
await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true });
50+
let doc = gBrowser.contentDocument;
51+
52+
await waitForAndAssertEtpStatusItemState(doc, {
53+
l10nId: "preferences-etp-level-standard",
54+
});
55+
56+
info("Switch to ETP `strict`");
57+
Services.prefs.setStringPref("browser.contentblocking.category", "strict");
58+
59+
await waitForAndAssertEtpStatusItemState(doc, {
60+
l10nId: "preferences-etp-level-strict",
61+
});
62+
63+
info("Switch to ETP `custom`");
64+
Services.prefs.setStringPref("browser.contentblocking.category", "custom");
65+
66+
await waitForAndAssertEtpStatusItemState(doc, {
67+
l10nId: "preferences-etp-level-custom",
68+
});
69+
70+
info("Switch back to default ETP `standard`");
71+
Services.prefs.clearUserPref("browser.contentblocking.category");
72+
73+
await waitForAndAssertEtpStatusItemState(doc, {
74+
l10nId: "preferences-etp-level-standard",
75+
});
76+
77+
gBrowser.removeCurrentTab();
78+
});
79+
80+
// Test that the protections dashboard link in the ETP status section opens the about:protections page.
81+
add_task(async function test_protections_dashboard_link() {
82+
await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true });
83+
let doc = gBrowser.contentDocument;
84+
85+
let protectionsDashboardLink = doc.getElementById("protectionsDashboardLink");
86+
87+
Assert.ok(
88+
BrowserTestUtils.isVisible(protectionsDashboardLink),
89+
"Protections dashboard link is visible."
90+
);
91+
92+
let linkPromise = BrowserTestUtils.waitForNewTab(
93+
gBrowser,
94+
"about:protections"
95+
);
96+
await BrowserTestUtils.synthesizeMouseAtCenter(
97+
"#protectionsDashboardLink",
98+
{},
99+
gBrowser.selectedBrowser
100+
);
101+
let tab = await linkPromise;
102+
103+
Assert.equal(
104+
tab.linkedBrowser.currentURI.spec,
105+
"about:protections",
106+
"Protections dashboard link opened the about:protections page."
107+
);
108+
109+
// about:protections tab.
110+
BrowserTestUtils.removeTab(tab);
111+
// Preferences tab.
112+
gBrowser.removeCurrentTab();
113+
});

browser/locales-preview/privacyPreferences.ftl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,28 @@ preferences-doh-custom-provider-label =
208208
209209
preferences-doh-header2 =
210210
.heading = DNS over HTTPS
211+
212+
## ETP status section
213+
214+
preferences-etp-status-header =
215+
.label = Enhanced Tracking Protection
216+
.description = Some sites use trackers to learn what you do online. { -brand-short-name } blocks many of them automatically to protect your privacy while you browse.
217+
218+
preferences-etp-level-standard =
219+
.label = Standard (default)
220+
.description = Blocks known trackers and cookies, helping protect your privacy without affecting most websites’ functionality.
221+
222+
preferences-etp-level-strict =
223+
.label = Strict
224+
.description = Stronger protection, but may cause some sites or content to break.
225+
226+
preferences-etp-level-custom =
227+
.label = Custom
228+
.description = Choose which trackers and scripts to block.
229+
230+
preferences-etp-status-advanced-button =
231+
.label = Advanced settings
232+
233+
preferences-etp-status-protections-dashboard-link =
234+
.label = View your personalized Protections Dashboard
235+
.description = See how many creepers { -brand-short-name } has blocked for you, including social media trackers, fingerprinters, and cryptominers.

0 commit comments

Comments
 (0)