Bug 1522567 - Add cryptomining and fingerprinting protection options to custom content blocking preferences. r=ewright,flod

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Johann Hofmann 2019-02-06 22:11:57 +00:00
parent ee2283d446
commit 1f44fbacda
12 changed files with 162 additions and 9 deletions

View File

@ -1554,6 +1554,9 @@ pref("browser.contentblocking.rejecttrackers.control-center.ui.enabled", true);
pref("browser.contentblocking.control-center.ui.showBlockedLabels", true);
pref("browser.contentblocking.control-center.ui.showAllowedLabels", false);
pref("browser.contentblocking.cryptomining.preferences.ui.enabled", false);
pref("browser.contentblocking.fingerprinting.preferences.ui.enabled", false);
// Enable the Report Breakage UI on Nightly and Beta but not on Release yet.
#ifdef EARLY_BETA_OR_EARLIER
pref("browser.contentblocking.reportBreakage.enabled", true);

View File

@ -987,8 +987,7 @@ BrowserGlue.prototype = {
os.removeObserver(this, "sync-ui-state:update");
os.removeObserver(this, "shield-init-complete");
Services.prefs.removeObserver("privacy.trackingprotection.enabled", this._matchCBCategory);
Services.prefs.removeObserver("privacy.trackingprotection.pbmode.enabled", this._matchCBCategory);
Services.prefs.removeObserver("privacy.trackingprotection", this._matchCBCategory);
Services.prefs.removeObserver("urlclassifier.trackingTable", this._matchCBCategory);
Services.prefs.removeObserver("network.cookie.cookieBehavior", this._matchCBCategory);
Services.prefs.removeObserver(ContentBlockingCategoriesPrefs.PREF_CB_CATEGORY, this._updateCBCategory);
@ -1363,8 +1362,8 @@ BrowserGlue.prototype = {
PlacesUtils.favicons.setDefaultIconURIPreferredSize(16 * aWindow.devicePixelRatio);
this._matchCBCategory();
Services.prefs.addObserver("privacy.trackingprotection.enabled", this._matchCBCategory);
Services.prefs.addObserver("privacy.trackingprotection.pbmode.enabled", this._matchCBCategory);
// This observes the entire privacy.trackingprotection.* pref tree.
Services.prefs.addObserver("privacy.trackingprotection", this._matchCBCategory);
Services.prefs.addObserver("urlclassifier.trackingTable", this._matchCBCategory);
Services.prefs.addObserver("network.cookie.cookieBehavior", this._matchCBCategory);
Services.prefs.addObserver(ContentBlockingCategoriesPrefs.PREF_CB_CATEGORY, this._updateCBCategory);
@ -2996,12 +2995,16 @@ var ContentBlockingCategoriesPrefs = {
["network.cookie.cookieBehavior", Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER],
["privacy.trackingprotection.pbmode.enabled", true],
["privacy.trackingprotection.enabled", true],
["privacy.trackingprotection.fingerprinting.enabled", null],
["privacy.trackingprotection.cryptomining.enabled", null],
],
standard: [
["urlclassifier.trackingTable", null],
["network.cookie.cookieBehavior", null],
["privacy.trackingprotection.pbmode.enabled", null],
["privacy.trackingprotection.enabled", null],
["privacy.trackingprotection.fingerprinting.enabled", null],
["privacy.trackingprotection.cryptomining.enabled", null],
],
},
switchingCategory: false,

View File

@ -41,9 +41,11 @@ XPCOMUtils.defineLazyGetter(this, "AlertsServiceDND", function() {
});
Preferences.addAll([
// Tracking Protection
// Content blocking / Tracking Protection
{ id: "privacy.trackingprotection.enabled", type: "bool" },
{ id: "privacy.trackingprotection.pbmode.enabled", type: "bool" },
{ id: "privacy.trackingprotection.fingerprinting.enabled", type: "bool" },
{ id: "privacy.trackingprotection.cryptomining.enabled", type: "bool" },
// Button prefs
{ id: "pref.privacy.disable_button.cookie_exceptions", type: "bool" },
@ -448,6 +450,14 @@ var gPrivacyPane = {
Preferences.get("browser.contentblocking.category").on("change",
gPrivacyPane.highlightCBCategory);
let cryptoMinersOption = document.getElementById("contentBlockingCryptominersOption");
let fingerprintersOption = document.getElementById("contentBlockingFingerprintersOption");
cryptoMinersOption.hidden =
!Services.prefs.getBoolPref("browser.contentblocking.cryptomining.preferences.ui.enabled");
fingerprintersOption.hidden =
!Services.prefs.getBoolPref("browser.contentblocking.fingerprinting.preferences.ui.enabled");
this.highlightCBCategory();
this.readBlockCookies();

View File

@ -106,7 +106,7 @@
<label class="content-blocking-warning-title" data-l10n-id="content-blocking-warning-title"/>
</hbox>
<description class="indent">
<html:span class="tail-with-learn-more" data-l10n-id="content-blocking-warning-desc"></html:span>
<html:span class="tail-with-learn-more" data-l10n-id="content-blocking-warning-description"></html:span>
<label class="text-link content-blocking-warning-learn-how" data-l10n-id="content-blocking-learn-how"/>
</description>
</vbox>
@ -175,6 +175,20 @@
</hbox>
</vbox>
</hbox>
<hbox class="custom-option" id="contentBlockingCryptominersOption">
<checkbox id="contentBlockingCryptominersCheckbox"
class="content-blocking-checkbox" flex="1"
preference="privacy.trackingprotection.cryptomining.enabled"
data-l10n-id="content-blocking-cryptominers-label"
aria-describedby="contentBlockingCustomDesc"/>
</hbox>
<hbox class="custom-option" id="contentBlockingFingerprintersOption">
<checkbox id="contentBlockingFingerprintersCheckbox"
class="content-blocking-checkbox" flex="1"
preference="privacy.trackingprotection.fingerprinting.enabled"
data-l10n-id="content-blocking-fingerprinters-label"
aria-describedby="contentBlockingCustomDesc"/>
</hbox>
<vbox class="content-blocking-warning">
<vbox class="indent">
<hbox>
@ -182,7 +196,7 @@
<label class="content-blocking-warning-title" data-l10n-id="content-blocking-warning-title"/>
</hbox>
<description class="indent">
<html:span class="tail-with-learn-more" data-l10n-id="content-blocking-warning-desc"></html:span>
<html:span class="tail-with-learn-more" data-l10n-id="content-blocking-warning-description"></html:span>
<label class="text-link content-blocking-warning-learn-how" data-l10n-id="content-blocking-learn-how"/>
</description>
</vbox>

View File

@ -8,6 +8,8 @@ const TP_PBM_PREF = "privacy.trackingprotection.pbmode.enabled";
const TP_LIST_PREF = "urlclassifier.trackingTable";
const NCB_PREF = "network.cookie.cookieBehavior";
const CAT_PREF = "browser.contentblocking.category";
const FP_PREF = "privacy.trackingprotection.fingerprinting.enabled";
const CM_PREF = "privacy.trackingprotection.cryptomining.enabled";
requestLongerTimeout(2);
@ -113,6 +115,8 @@ add_task(async function testContentBlockingStandardCategory() {
[TP_PREF]: null,
[TP_PBM_PREF]: null,
[NCB_PREF]: null,
[FP_PREF]: null,
[CM_PREF]: null,
};
for (let pref in prefs) {
@ -135,6 +139,8 @@ add_task(async function testContentBlockingStandardCategory() {
Services.prefs.setBoolPref(TP_PREF, true);
Services.prefs.setBoolPref(TP_PBM_PREF, false);
Services.prefs.setIntPref(NCB_PREF, Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER);
Services.prefs.setBoolPref(FP_PREF, true);
Services.prefs.setBoolPref(CM_PREF, true);
for (let pref in prefs) {
switch (Services.prefs.getPrefType(pref)) {
@ -197,13 +203,15 @@ add_task(async function testContentBlockingStrictCategory() {
is(Services.prefs.getBoolPref(TP_PBM_PREF), true, `${TP_PBM_PREF} has been set to true`);
is(Services.prefs.getIntPref(NCB_PREF), Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER, `${NCB_PREF} has been set to ${Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER}`);
ok(!Services.prefs.prefHasUserValue(TP_LIST_PREF), `reset the pref ${TP_LIST_PREF}`);
ok(!Services.prefs.prefHasUserValue(FP_PREF), `reset the pref ${FP_PREF}`);
ok(!Services.prefs.prefHasUserValue(CM_PREF), `reset the pref ${CM_PREF}`);
gBrowser.removeCurrentTab();
});
// Tests that the content blocking "Custom" category behaves as expected.
add_task(async function testContentBlockingCustomCategory() {
let prefs = [TP_LIST_PREF, TP_PREF, TP_PBM_PREF, NCB_PREF];
let prefs = [TP_LIST_PREF, TP_PREF, TP_PBM_PREF, NCB_PREF, FP_PREF, CM_PREF];
await openPreferencesViaOpenPreferencesAPI("privacy", {leaveOpen: true});
let doc = gBrowser.contentDocument;
@ -234,6 +242,16 @@ add_task(async function testContentBlockingCustomCategory() {
strictRadioOption.click();
await TestUtils.waitForCondition(() => Services.prefs.getStringPref(CAT_PREF) == "strict");
// Changing the FP_PREF and CM_PREF should necessarily set CAT_PREF to "custom"
for (let pref of [FP_PREF, CM_PREF]) {
Services.prefs.setBoolPref(pref, true);
await TestUtils.waitForCondition(() => Services.prefs.prefHasUserValue(pref));
is(Services.prefs.getStringPref(CAT_PREF), "custom", `${CAT_PREF} has been set to custom`);
strictRadioOption.click();
await TestUtils.waitForCondition(() => Services.prefs.getStringPref(CAT_PREF) == "strict");
}
// Changing the NCB_PREF should necessarily set CAT_PREF to "custom"
let defaultNCB = defaults.get(NCB_PREF);
let nonDefaultNCB;
@ -291,3 +309,49 @@ add_task(async function testContentBlockingDependentTPControls() {
gBrowser.removeCurrentTab();
});
// Checks that cryptomining and fingerprinting visibility can be controlled via pref.
add_task(async function testCustomOptionsVisibility() {
Services.prefs.setBoolPref("browser.contentblocking.cryptomining.preferences.ui.enabled", false);
Services.prefs.setBoolPref("browser.contentblocking.fingerprinting.preferences.ui.enabled", false);
await openPreferencesViaOpenPreferencesAPI("privacy", {leaveOpen: true});
let doc = gBrowser.contentDocument;
let cryptominersOption = doc.getElementById("contentBlockingCryptominersOption");
let fingerprintersOption = doc.getElementById("contentBlockingFingerprintersOption");
ok(cryptominersOption.hidden, "Cryptomining is hidden");
ok(fingerprintersOption.hidden, "Fingerprinting is hidden");
gBrowser.removeCurrentTab();
Services.prefs.setBoolPref("browser.contentblocking.cryptomining.preferences.ui.enabled", true);
await openPreferencesViaOpenPreferencesAPI("privacy", {leaveOpen: true});
doc = gBrowser.contentDocument;
cryptominersOption = doc.getElementById("contentBlockingCryptominersOption");
fingerprintersOption = doc.getElementById("contentBlockingFingerprintersOption");
ok(!cryptominersOption.hidden, "Cryptomining is shown");
ok(fingerprintersOption.hidden, "Fingerprinting is hidden");
gBrowser.removeCurrentTab();
Services.prefs.setBoolPref("browser.contentblocking.fingerprinting.preferences.ui.enabled", true);
await openPreferencesViaOpenPreferencesAPI("privacy", {leaveOpen: true});
doc = gBrowser.contentDocument;
cryptominersOption = doc.getElementById("contentBlockingCryptominersOption");
fingerprintersOption = doc.getElementById("contentBlockingFingerprintersOption");
ok(!cryptominersOption.hidden, "Cryptomining is shown");
ok(!fingerprintersOption.hidden, "Fingerprinting is shown");
gBrowser.removeCurrentTab();
Services.prefs.clearUserPref("browser.contentblocking.cryptomining.preferences.ui.enabled");
Services.prefs.clearUserPref("browser.contentblocking.fingerprinting.preferences.ui.enabled");
});

View File

@ -847,7 +847,7 @@ content-blocking-all-windows-trackers = Known trackers in all windows
content-blocking-all-third-party-cookies = All third-party cookies
content-blocking-warning-title = Heads up!
content-blocking-warning-desc = Blocking cookies and trackers can cause some websites to break. Its easy to disable blocking for sites you trust.
content-blocking-warning-description = Blocking content can cause some websites to break. Its easy to disable blocking for sites you trust.
content-blocking-learn-how = Learn how
content-blocking-trackers-label =
@ -865,6 +865,17 @@ content-blocking-cookies-label =
.label = Cookies
.accesskey = C
# Cryptomining refers to using scripts on websites that can use a computers resources to mine cryptocurrency without a users knowledge.
content-blocking-cryptominers-label =
.label = Cryptominers
.accesskey = y
# Browser fingerprinting is a method of tracking users by the configuration and settings information (their "digital fingerprint")
# that is visible to websites they browse, rather than traditional tracking methods such as IP addresses and unique cookies.
content-blocking-fingerprinters-label =
.label = Fingerprinters
.accesskey = F
## Privacy Section - Tracking
tracking-manage-exceptions =

View File

@ -0,0 +1,7 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="context-fill" fill-opacity="context-fill-opacity">
<path d="M14.71 1.29a1 1 0 0 0-1.42 0l-.7.71H9v-.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5V2H5a2 2 0 0 0-1.6.8L2.2 4.4A1 1 0 0 0 3 6h4v1.59l-5.71 5.7a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l12-12a1 1 0 0 0 0-1.42z"/>
<path d="M7 14.5a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5V10l-2 2z"/>
</svg>

After

Width:  |  Height:  |  Size: 611 B

View File

@ -0,0 +1,6 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="context-fill" fill-opacity="context-fill-opacity">
<path d="M13 2H9v-.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5V2H5a2 2 0 0 0-1.6.8L2.2 4.4A1 1 0 0 0 3 6h4v8.5a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5V6h4z"/>
</svg>

After

Width:  |  Height:  |  Size: 486 B

View File

@ -0,0 +1,8 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="context-fill" fill-opacity="context-fill-opacity">
<path d="M14.71 1.29a1 1 0 0 0-1.42 0l-.56.57A7 7 0 0 0 1 7a1 1 0 0 0 2 0 5 5 0 0 1 5-5 5 5 0 0 1 3.31 1.28l-.7.7A4 4 0 0 0 8 3a4 4 0 0 0-4 4 2 2 0 0 1-2 2 1 1 0 0 0 0 2 3.86 3.86 0 0 0 2.33-.75l-3 3a.91.91 0 0 0-.08.13.82.82 0 0 0-.11.17 1.17 1.17 0 0 0-.06.2A.86.86 0 0 0 1 14a.61.61 0 0 0 0 .23.62.62 0 0 0 0 .13v.08a.76.76 0 0 0 .12.19s0 .06.06.09a1 1 0 0 0 1.42 0l12-12a1 1 0 0 0 .11-1.43zM6 7a2 2 0 0 1 2-2 1.94 1.94 0 0 1 1.18.41l-.72.72A.91.91 0 0 0 8 6a1 1 0 0 0-1 1 4.76 4.76 0 0 1-.06.65L5.12 9.47A4.1 4.1 0 0 0 6 7z"/>
<path d="M9.68 9.32a8.06 8.06 0 0 1-1.42 2.48 11 11 0 0 0-1.15 1.75 1 1 0 0 0 .44 1.34A.93.93 0 0 0 8 15a1 1 0 0 0 .89-.55 9.74 9.74 0 0 1 1-1.44A8.84 8.84 0 0 0 12 7z"/>
<path d="M12.91 6.09A5.5 5.5 0 0 1 13 7a8.24 8.24 0 0 1-1.14 4.28A5.75 5.75 0 0 0 11 14a1 1 0 0 0 2 0 3.91 3.91 0 0 1 .63-1.79A10.18 10.18 0 0 0 15 7a6.81 6.81 0 0 0-.48-2.52z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,8 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="context-fill" fill-opacity="context-fill-opacity">
<path d="M8 0a7 7 0 0 0-7 7 1 1 0 0 0 2 0 5 5 0 0 1 10 0 8.24 8.24 0 0 1-1.14 4.28A5.75 5.75 0 0 0 11 14a1 1 0 0 0 2 0 3.91 3.91 0 0 1 .63-1.79A10.18 10.18 0 0 0 15 7a7 7 0 0 0-7-7z"/>
<path d="M8 3a4 4 0 0 0-4 4 2 2 0 0 1-2 2 1 1 0 0 0 0 2 4 4 0 0 0 4-4 2 2 0 0 1 4 0 6.88 6.88 0 0 1-1.74 4.8 11 11 0 0 0-1.15 1.75 1 1 0 0 0 .44 1.34A.93.93 0 0 0 8 15a1 1 0 0 0 .89-.55 9.74 9.74 0 0 1 1-1.44A8.84 8.84 0 0 0 12 7a4 4 0 0 0-4-4z"/>
<path d="M8 6a1 1 0 0 0-1 1c0 4.21-5.26 6-5.32 6.05a1 1 0 0 0-.63 1.27A1 1 0 0 0 2 15a1.25 1.25 0 0 0 .32 0C2.59 14.86 9 12.66 9 7a1 1 0 0 0-1-1z"/>
</svg>

After

Width:  |  Height:  |  Size: 924 B

View File

@ -34,6 +34,21 @@
list-style-image: url("chrome://browser/skin/controlcenter/3rdpartycookies-disabled.svg");
}
#contentBlockingCryptominersCheckbox > .checkbox-label-box {
list-style-image: url("chrome://browser/skin/controlcenter/cryptominers.svg");
}
#contentBlockingCryptominersCheckbox[checked] > .checkbox-label-box {
list-style-image: url("chrome://browser/skin/controlcenter/cryptominers-disabled.svg");
}
#contentBlockingFingerprintersCheckbox > .checkbox-label-box {
list-style-image: url("chrome://browser/skin/controlcenter/fingerprinters.svg");
}
#contentBlockingFingerprintersCheckbox[checked] > .checkbox-label-box {
list-style-image: url("chrome://browser/skin/controlcenter/fingerprinters-disabled.svg");
}
.content-blocking-icon,
.permission-icon {

View File

@ -27,8 +27,12 @@
skin/classic/browser/controlcenter/3rdpartycookies-disabled.svg (../shared/controlcenter/3rdpartycookies-disabled.svg)
skin/classic/browser/controlcenter/conn-not-secure.svg (../shared/controlcenter/conn-not-secure.svg)
skin/classic/browser/controlcenter/connection.svg (../shared/controlcenter/connection.svg)
skin/classic/browser/controlcenter/cryptominers.svg (../shared/controlcenter/cryptominers.svg)
skin/classic/browser/controlcenter/cryptominers-disabled.svg (../shared/controlcenter/cryptominers-disabled.svg)
skin/classic/browser/controlcenter/mcb-disabled.svg (../shared/controlcenter/mcb-disabled.svg)
skin/classic/browser/controlcenter/extension.svg (../shared/controlcenter/extension.svg)
skin/classic/browser/controlcenter/fingerprinters.svg (../shared/controlcenter/fingerprinters.svg)
skin/classic/browser/controlcenter/fingerprinters-disabled.svg (../shared/controlcenter/fingerprinters-disabled.svg)
skin/classic/browser/controlcenter/info.svg (../shared/controlcenter/info.svg)
skin/classic/browser/controlcenter/permissions.svg (../shared/controlcenter/permissions.svg)
skin/classic/browser/controlcenter/trackers.svg (../shared/controlcenter/trackers.svg)