Bug 1572487 - Add UI Test for STP Pref with Preferences r=johannh

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
mcrawford@mozilla.com 2019-08-21 14:45:21 +00:00
Родитель c975d5be60
Коммит 549982a317
2 изменённых файлов: 71 добавлений и 4 удалений

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

@ -67,6 +67,7 @@ add_task(async function testContentBlockingMainCategory() {
let prefs = [
[TP_PREF, false],
[TP_PBM_PREF, true],
[STP_PREF, false],
[NCB_PREF, Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER],
];
@ -542,7 +543,8 @@ add_task(async function testContentBlockingDependentTPControls() {
gBrowser.removeCurrentTab();
});
// Checks that cryptomining and fingerprinting visibility can be controlled via pref.
// Checks that social media trackers, cryptomining and fingerprinting visibility
// can be controlled via pref.
add_task(async function testCustomOptionsVisibility() {
Services.prefs.setBoolPref(
"browser.contentblocking.cryptomining.preferences.ui.enabled",
@ -552,6 +554,10 @@ add_task(async function testCustomOptionsVisibility() {
"browser.contentblocking.fingerprinting.preferences.ui.enabled",
false
);
Services.prefs.setBoolPref(
"privacy.socialtracking.block_cookies.enabled",
false
);
await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true });
@ -604,12 +610,44 @@ add_task(async function testCustomOptionsVisibility() {
gBrowser.removeCurrentTab();
// Social media trackers UI should be hidden
await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true });
doc = gBrowser.contentDocument;
let socialTrackingUI = [...doc.querySelectorAll(".social-media-option")];
ok(
socialTrackingUI.every(el => el.hidden),
"All Social media tracker UI instances are hidden"
);
gBrowser.removeCurrentTab();
// Social media trackers UI should be visible
Services.prefs.setBoolPref(
"privacy.socialtracking.block_cookies.enabled",
true
);
await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true });
doc = gBrowser.contentDocument;
socialTrackingUI = [...doc.querySelectorAll(".social-media-option")];
ok(
!socialTrackingUI.every(el => el.hidden),
"All Social media tracker UI instances are visible"
);
gBrowser.removeCurrentTab();
Services.prefs.clearUserPref(
"browser.contentblocking.cryptomining.preferences.ui.enabled"
);
Services.prefs.clearUserPref(
"browser.contentblocking.fingerprinting.preferences.ui.enabled"
);
Services.prefs.clearUserPref("privacy.socialtracking.block_cookies.enabled");
});
// Checks that adding a custom enterprise policy will put the user in the custom category.

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

@ -15,6 +15,7 @@ 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";
const STP_PREF = "privacy.trackingprotection.socialtracking.enabled";
const STRICT_DEF_PREF = "browser.contentblocking.features.strict";
// Tests that the content blocking standard category definition is based on the default settings of
@ -45,6 +46,10 @@ add_task(async function testContentBlockingStandardDefinition() {
!Services.prefs.prefHasUserValue(CM_PREF),
`${CM_PREF} pref has the default value`
);
ok(
!Services.prefs.prefHasUserValue(STP_PREF),
`${STP_PREF} pref has the default value`
);
ok(
!Services.prefs.prefHasUserValue(NCB_PREF),
`${NCB_PREF} pref has the default value`
@ -55,6 +60,7 @@ add_task(async function testContentBlockingStandardDefinition() {
let originalTPPBM = defaults.getBoolPref(TP_PBM_PREF);
let originalFP = defaults.getBoolPref(FP_PREF);
let originalCM = defaults.getBoolPref(CM_PREF);
let originalSTP = defaults.getBoolPref(STP_PREF);
let originalNCB = defaults.getIntPref(NCB_PREF);
let nonDefaultNCB;
@ -71,6 +77,7 @@ add_task(async function testContentBlockingStandardDefinition() {
defaults.setBoolPref(TP_PBM_PREF, !originalTPPBM);
defaults.setBoolPref(FP_PREF, !originalFP);
defaults.setBoolPref(CM_PREF, !originalCM);
defaults.setBoolPref(CM_PREF, !originalSTP);
defaults.setIntPref(NCB_PREF, !originalNCB);
ok(
@ -89,6 +96,10 @@ add_task(async function testContentBlockingStandardDefinition() {
!Services.prefs.prefHasUserValue(CM_PREF),
`${CM_PREF} pref has the default value`
);
ok(
!Services.prefs.prefHasUserValue(STP_PREF),
`${STP_PREF} pref has the default value`
);
ok(
!Services.prefs.prefHasUserValue(NCB_PREF),
`${NCB_PREF} pref has the default value`
@ -100,6 +111,7 @@ add_task(async function testContentBlockingStandardDefinition() {
defaults.setBoolPref(TP_PBM_PREF, originalTPPBM);
defaults.setBoolPref(FP_PREF, originalFP);
defaults.setBoolPref(CM_PREF, originalCM);
defaults.setBoolPref(STP_PREF, originalSTP);
defaults.setIntPref(NCB_PREF, originalNCB);
});
@ -109,7 +121,10 @@ add_task(async function testContentBlockingStandardDefinition() {
add_task(async function testContentBlockingStrictDefinition() {
let defaults = Services.prefs.getDefaultBranch("");
let originalStrictPref = defaults.getStringPref(STRICT_DEF_PREF);
defaults.setStringPref(STRICT_DEF_PREF, "tp,tpPrivate,fp,cm,cookieBehavior0");
defaults.setStringPref(
STRICT_DEF_PREF,
"tp,tpPrivate,fp,cm,cookieBehavior0,stp"
);
Services.prefs.setStringPref(CAT_PREF, "strict");
is(
Services.prefs.getStringPref(CAT_PREF),
@ -123,7 +138,7 @@ add_task(async function testContentBlockingStrictDefinition() {
);
is(
Services.prefs.getStringPref(STRICT_DEF_PREF),
"tp,tpPrivate,fp,cm,cookieBehavior0",
"tp,tpPrivate,fp,cm,cookieBehavior0,stp",
`${STRICT_DEF_PREF} changed to what we set.`
);
@ -147,6 +162,11 @@ add_task(async function testContentBlockingStrictDefinition() {
true,
`${CM_PREF} pref has been set to true`
);
is(
Services.prefs.getBoolPref(STP_PREF),
true,
`${STP_PREF} pref has been set to true`
);
is(
Services.prefs.getIntPref(NCB_PREF),
Ci.nsICookieService.BEHAVIOR_ACCEPT,
@ -172,6 +192,10 @@ add_task(async function testContentBlockingStrictDefinition() {
!Services.prefs.prefHasUserValue(CM_PREF),
`${CM_PREF} pref has the default value`
);
ok(
!Services.prefs.prefHasUserValue(STP_PREF),
`${STP_PREF} pref has the default value`
);
ok(
!Services.prefs.prefHasUserValue(NCB_PREF),
`${NCB_PREF} pref has the default value`
@ -179,7 +203,7 @@ add_task(async function testContentBlockingStrictDefinition() {
defaults.setStringPref(
STRICT_DEF_PREF,
"-tpPrivate,-fp,-cm,-tp,cookieBehavior3"
"-tpPrivate,-fp,-cm,-tp,cookieBehavior3,-stp"
);
is(
Services.prefs.getBoolPref(TP_PREF),
@ -201,6 +225,11 @@ add_task(async function testContentBlockingStrictDefinition() {
false,
`${CM_PREF} pref has been set to false`
);
is(
Services.prefs.getBoolPref(STP_PREF),
false,
`${STP_PREF} pref has been set to false`
);
is(
Services.prefs.getIntPref(NCB_PREF),
Ci.nsICookieService.BEHAVIOR_LIMIT_FOREIGN,