Bug 1483727 - Correctly test the TP UI state when CB UI is off. r=francois
authorJohann Hofmann <jhofmann@mozilla.com>
Thu, 23 Aug 2018 21:31:22 +0000
changeset 481560 2622040931e64baff36decfec3cec21301f02270
parent 481559 9b41ca132dbc6462cc5afbd52b06a9a9b5b00c12
child 481561 73ffc23ea21b0b78a5f85fac1f475164a8b2dd8c
push id232
push userfmarier@mozilla.com
push dateWed, 05 Sep 2018 20:45:54 +0000
reviewersfrancois
bugs1483727
milestone63.0a1
Bug 1483727 - Correctly test the TP UI state when CB UI is off. r=francois Differential Revision: https://phabricator.services.mozilla.com/D4167
browser/base/content/test/trackingUI/browser_trackingUI_state.js
--- a/browser/base/content/test/trackingUI/browser_trackingUI_state.js
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_state.js
@@ -12,17 +12,17 @@
  *     2) A page with tracking elements is loaded.
  *
  * See also Bugs 1175327, 1043801, 1178985
  */
 
 const CB_PREF = "browser.contentblocking.enabled";
 const CB_UI_PREF = "browser.contentblocking.ui.enabled";
 const TP_PREF = "privacy.trackingprotection.enabled";
-const TP_PB_PREF = "privacy.trackingprotection.enabled";
+const TP_PB_PREF = "privacy.trackingprotection.pbmode.enabled";
 const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/benignPage.html";
 const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html";
 var ContentBlocking = null;
 var TrackingProtection = null;
 var tabbrowser = null;
 
 registerCleanupFunction(function() {
   TrackingProtection = ContentBlocking = tabbrowser = null;
@@ -271,42 +271,55 @@ add_task(async function testNormalBrowsi
 
   Services.prefs.setBoolPref(TP_PREF, true);
   ok(TrackingProtection.enabled, "TP is enabled after setting the pref");
   Services.prefs.setBoolPref(CB_PREF, true);
   ok(ContentBlocking.enabled, "CB is enabled after setting the pref");
 
   await testContentBlockingEnabled(tab);
 
-  Services.prefs.setBoolPref(CB_PREF, false);
-  ok(!ContentBlocking.enabled, "CB is disabled after setting the pref");
+  if (Services.prefs.getBoolPref(CB_UI_PREF)) {
+    Services.prefs.setBoolPref(CB_PREF, false);
+    ok(!ContentBlocking.enabled, "CB is disabled after setting the pref");
+  } else {
+    Services.prefs.setBoolPref(TP_PREF, false);
+    ok(!TrackingProtection.enabled, "TP is disabled after setting the pref");
+  }
 
   await testContentBlockingDisabled(tab);
 
   gBrowser.removeCurrentTab();
 });
 
 add_task(async function testPrivateBrowsing() {
   let privateWin = await BrowserTestUtils.openNewBrowserWindow({private: true});
   tabbrowser = privateWin.gBrowser;
   let tab = tabbrowser.selectedTab = BrowserTestUtils.addTab(tabbrowser);
 
+  // Set the normal mode pref to false to check the pbmode pref.
+  Services.prefs.setBoolPref(TP_PREF, false);
+
   ContentBlocking = tabbrowser.ownerGlobal.ContentBlocking;
   ok(ContentBlocking, "CB is attached to the private window");
   TrackingProtection = tabbrowser.ownerGlobal.TrackingProtection;
   ok(TrackingProtection, "TP is attached to the private window");
   is(TrackingProtection.enabled, Services.prefs.getBoolPref(TP_PB_PREF),
      "TP.enabled is based on the pb pref value");
 
   Services.prefs.setBoolPref(TP_PB_PREF, true);
   ok(TrackingProtection.enabled, "TP is enabled after setting the pref");
   Services.prefs.setBoolPref(CB_PREF, true);
   ok(TrackingProtection.enabled, "CB is enabled after setting the pref");
 
   await testContentBlockingEnabled(tab);
 
-  Services.prefs.setBoolPref(CB_PREF, false);
-  ok(!ContentBlocking.enabled, "CB is disabled after setting the pref");
+  if (Services.prefs.getBoolPref(CB_UI_PREF)) {
+    Services.prefs.setBoolPref(CB_PREF, false);
+    ok(!ContentBlocking.enabled, "CB is disabled after setting the pref");
+  } else {
+    Services.prefs.setBoolPref(TP_PB_PREF, false);
+    ok(!TrackingProtection.enabled, "TP is disabled after setting the pref");
+  }
 
   await testContentBlockingDisabled(tab);
 
   privateWin.close();
 });