Bug 1527891 - Fix copy-paste error in browser-contentblocking.js, update category labels when pref changes for fp and cm. r=ewright

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Johann Hofmann 2019-02-20 15:36:58 +00:00
Родитель e588cab7bc
Коммит d9b61c5c4b
2 изменённых файлов: 40 добавлений и 4 удалений

Просмотреть файл

@ -15,7 +15,8 @@ var Fingerprinting = {
},
init() {
XPCOMUtils.defineLazyPreferenceGetter(this, "enabled", this.PREF_ENABLED, false);
XPCOMUtils.defineLazyPreferenceGetter(this, "enabled", this.PREF_ENABLED, false,
() => this.updateCategoryLabel());
this.updateCategoryLabel();
},
@ -39,9 +40,9 @@ var Fingerprinting = {
updateCategoryLabel() {
let label;
if (this.enabled) {
label = ContentBlocking.showBlockedLabels ? "contentBlocking.cryptominers.blocking.label" : null;
label = ContentBlocking.showBlockedLabels ? "contentBlocking.fingerprinters.blocking.label" : null;
} else {
label = ContentBlocking.showAllowedLabels ? "contentBlocking.cryptominers.allowed.label" : null;
label = ContentBlocking.showAllowedLabels ? "contentBlocking.fingerprinters.allowed.label" : null;
}
this.categoryLabel.textContent = label ? gNavigatorBundle.getString(label) : "";
},
@ -126,7 +127,8 @@ var Cryptomining = {
},
init() {
XPCOMUtils.defineLazyPreferenceGetter(this, "enabled", this.PREF_ENABLED, false);
XPCOMUtils.defineLazyPreferenceGetter(this, "enabled", this.PREF_ENABLED, false,
() => this.updateCategoryLabel());
this.updateCategoryLabel();
},

Просмотреть файл

@ -3,6 +3,8 @@ const TP_PREF = "privacy.trackingprotection.enabled";
const TP_PB_PREF = "privacy.trackingprotection.pbmode.enabled";
const TPC_PREF = "network.cookie.cookieBehavior";
const TT_PREF = "urlclassifier.trackingTable";
const CM_PREF = "privacy.trackingprotection.cryptomining.enabled";
const FP_PREF = "privacy.trackingprotection.fingerprinting.enabled";
ChromeUtils.import("resource://testing-common/CustomizableUITestUtils.jsm", this);
@ -12,6 +14,8 @@ registerCleanupFunction(function() {
Services.prefs.clearUserPref(TPC_PREF);
Services.prefs.clearUserPref(TT_PREF);
Services.prefs.clearUserPref(CAT_PREF);
Services.prefs.clearUserPref(CM_PREF);
Services.prefs.clearUserPref(FP_PREF);
});
add_task(async function testCategoryLabelsInControlPanel() {
@ -123,5 +127,35 @@ add_task(async function testSubcategoryLabels() {
gNavigatorBundle.getString("contentBlocking.cookies.blockingUnvisited.label"),
"The category label has updated correctly");
is(categoryLabel.textContent, gNavigatorBundle.getString("contentBlocking.cookies.blockingUnvisited.label"));
categoryLabel =
document.getElementById("identity-popup-content-blocking-fingerprinters-state-label");
Services.prefs.setBoolPref(FP_PREF, true);
await TestUtils.waitForCondition(() => categoryLabel.textContent ==
gNavigatorBundle.getString("contentBlocking.fingerprinters.blocking.label"),
"The category label has updated correctly");
is(categoryLabel.textContent, gNavigatorBundle.getString("contentBlocking.fingerprinters.blocking.label"));
Services.prefs.setBoolPref(FP_PREF, false);
await TestUtils.waitForCondition(() => categoryLabel.textContent ==
gNavigatorBundle.getString("contentBlocking.fingerprinters.allowed.label"),
"The category label has updated correctly");
is(categoryLabel.textContent, gNavigatorBundle.getString("contentBlocking.fingerprinters.allowed.label"));
categoryLabel =
document.getElementById("identity-popup-content-blocking-cryptominers-state-label");
Services.prefs.setBoolPref(CM_PREF, true);
await TestUtils.waitForCondition(() => categoryLabel.textContent ==
gNavigatorBundle.getString("contentBlocking.cryptominers.blocking.label"),
"The category label has updated correctly");
is(categoryLabel.textContent, gNavigatorBundle.getString("contentBlocking.cryptominers.blocking.label"));
Services.prefs.setBoolPref(CM_PREF, false);
await TestUtils.waitForCondition(() => categoryLabel.textContent ==
gNavigatorBundle.getString("contentBlocking.cryptominers.allowed.label"),
"The category label has updated correctly");
is(categoryLabel.textContent, gNavigatorBundle.getString("contentBlocking.cryptominers.allowed.label"));
});
});