Bug 1545074 - Future-proof the strict category expectations. r=johannh
authorErica Wright <ewright@mozilla.com>
Wed, 17 Apr 2019 16:39:31 +0000
changeset 469880 02b89c29412b6c1444fe32a4847e5261e2bb3d00
parent 469879 f4eee626f2c84eeac8aa5033ebceeec0a4419706
child 469881 b978367ef7bb80e73e9c93c6234757731b5e58fb
child 470033 5d0134101bec2a21d5142bdddf8f57f24d0f4720
push id35883
push userbtara@mozilla.com
push dateWed, 17 Apr 2019 21:47:29 +0000
treeherdermozilla-central@02b89c29412b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1545074
milestone68.0a1
first release with
nightly linux32
02b89c29412b / 68.0a1 / 20190417214729 / files
nightly linux64
02b89c29412b / 68.0a1 / 20190417214729 / files
nightly mac
02b89c29412b / 68.0a1 / 20190417214729 / files
nightly win32
02b89c29412b / 68.0a1 / 20190417214729 / files
nightly win64
02b89c29412b / 68.0a1 / 20190417214729 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1545074 - Future-proof the strict category expectations. r=johannh Differential Revision: https://phabricator.services.mozilla.com/D27906
browser/components/preferences/in-content/tests/browser_contentblocking.js
--- a/browser/components/preferences/in-content/tests/browser_contentblocking.js
+++ b/browser/components/preferences/in-content/tests/browser_contentblocking.js
@@ -5,16 +5,17 @@ ChromeUtils.defineModuleGetter(this, "Pr
 
 const TP_PREF = "privacy.trackingprotection.enabled";
 const TP_PBM_PREF = "privacy.trackingprotection.pbmode.enabled";
 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 PREF_TEST_NOTIFICATIONS = "browser.safebrowsing.test-notifications.enabled";
+const STRICT_PREF = "browser.contentblocking.features.strict";
 
 const {
   EnterprisePolicyTesting,
   PoliciesPrefTracker,
 } = ChromeUtils.import("resource://testing-common/EnterprisePolicyTesting.jsm", null);
 
 requestLongerTimeout(2);
 
@@ -213,32 +214,74 @@ add_task(async function testContentBlock
   gBrowser.removeCurrentTab();
 });
 
 // Tests that the content blocking "Strict" category radio sets the prefs to the expected values.
 add_task(async function testContentBlockingStrictCategory() {
   Services.prefs.setBoolPref(TP_PREF, false);
   Services.prefs.setBoolPref(TP_PBM_PREF, false);
   Services.prefs.setIntPref(NCB_PREF, Ci.nsICookieService.BEHAVIOR_LIMIT_FOREIGN);
+  let strict_pref = Services.prefs.getStringPref(STRICT_PREF).split(",");
 
   await openPreferencesViaOpenPreferencesAPI("privacy", {leaveOpen: true});
   let doc = gBrowser.contentDocument;
 
   let strictRadioOption = doc.getElementById("strictRadio");
   strictRadioOption.click();
 
   // TP prefs are reset async to check for extensions controlling them.
-  await TestUtils.waitForCondition(() => Services.prefs.prefHasUserValue(TP_PREF));
-
-  is(Services.prefs.getStringPref(CAT_PREF), "strict", `${CAT_PREF} has been set to strict`);
-  is(Services.prefs.getBoolPref(TP_PREF), true, `${TP_PREF} has been set to true`);
-  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(FP_PREF), `reset the pref ${FP_PREF}`);
-  ok(!Services.prefs.prefHasUserValue(CM_PREF), `reset the pref ${CM_PREF}`);
+  await TestUtils.waitForCondition(() => Services.prefs.getStringPref(CAT_PREF) == "strict");
+  // Depending on the definition of the STRICT_PREF, the dependant prefs may have been
+  // set to varying values. Ensure they have been set according to this definition.
+  for (let pref of strict_pref) {
+    switch (pref) {
+    case "tp":
+      is(Services.prefs.getBoolPref(TP_PREF), true, `${TP_PREF} has been set to true`);
+      break;
+    case "-tp":
+      is(Services.prefs.getBoolPref(TP_PREF), false, `${TP_PREF} has been set to false`);
+      break;
+    case "tpPrivate":
+      is(Services.prefs.getBoolPref(TP_PBM_PREF), true, `${TP_PBM_PREF} has been set to true`);
+      break;
+    case "-tpPrivate":
+      is(Services.prefs.getBoolPref(TP_PBM_PREF), false, `${TP_PBM_PREF} has been set to false`);
+      break;
+    case "fp":
+      is(Services.prefs.getBoolPref(FP_PREF), true, `${FP_PREF} has been set to true`);
+      break;
+    case "-fp":
+      is(Services.prefs.getBoolPref(FP_PREF), false, `${FP_PREF} has been set to false`);
+      break;
+    case "cm":
+      is(Services.prefs.getBoolPref(CM_PREF), true, `${CM_PREF} has been set to true`);
+      break;
+    case "-cm":
+      is(Services.prefs.getBoolPref(CM_PREF), false, `${CM_PREF} has been set to false`);
+      break;
+    case "cookieBehavior0":
+      is(Services.prefs.getIntPref(NCB_PREF), Ci.nsICookieService.BEHAVIOR_ACCEPT, `${NCB_PREF} has been set to ${Ci.nsICookieService.BEHAVIOR_ACCEPT}`);
+      break;
+    case "cookieBehavior1":
+      is(Services.prefs.getIntPref(NCB_PREF), Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN, `${NCB_PREF} has been set to ${Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN}`);
+      break;
+    case "cookieBehavior2":
+      is(Services.prefs.getIntPref(NCB_PREF), Ci.nsICookieService.BEHAVIOR_REJECT, `${NCB_PREF} has been set to ${Ci.nsICookieService.BEHAVIOR_REJECT}`);
+      break;
+    case "cookieBehavior3":
+      is(Services.prefs.getIntPref(NCB_PREF), Ci.nsICookieService.BEHAVIOR_LIMIT_FOREIGN, `${NCB_PREF} has been set to ${Ci.nsICookieService.BEHAVIOR_LIMIT_FOREIGN}`);
+      break;
+    case "cookieBehavior4":
+      is(Services.prefs.getIntPref(NCB_PREF), Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER, `${NCB_PREF} has been set to ${Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER}`);
+      break;
+    default:
+      ok(false, "unknown option was added to the strict pref");
+      break;
+    }
+  }
 
   gBrowser.removeCurrentTab();
 });
 
 // Tests that the content blocking "Custom" category behaves as expected.
 add_task(async function testContentBlockingCustomCategory() {
   let prefs = [TP_PREF, TP_PBM_PREF, NCB_PREF, FP_PREF, CM_PREF];