Bug 1483378 - Part 4: Enable hiding the "reject trackers" menu item based on a preference; r=johannh
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 16 Aug 2018 13:10:21 -0400
changeset 432381 3b5f60a54a1276e1c76f7d4291c02e9e936e544e
parent 432380 547b082422b014de300723eb2b7ad679545012e5
child 432382 b3c038572979338ba2feae669ac7567f11c3264e
push id106719
push usereakhgari@mozilla.com
push dateMon, 20 Aug 2018 15:42:45 +0000
treeherdermozilla-inbound@b3c038572979 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1483378
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1483378 - Part 4: Enable hiding the "reject trackers" menu item based on a preference; r=johannh
browser/app/profile/firefox.js
browser/components/preferences/in-content/privacy.js
browser/components/preferences/in-content/tests/browser.ini
browser/components/preferences/in-content/tests/browser_privacypane_2.js
browser/components/preferences/in-content/tests/browser_privacypane_4.js
browser/components/preferences/in-content/tests/privacypane_tests_perwindow.js
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1483,16 +1483,17 @@ pref("browser.ping-centre.telemetry", tr
 pref("browser.ping-centre.log", false);
 pref("browser.ping-centre.staging.endpoint", "https://onyx_tiles.stage.mozaws.net/v3/links/ping-centre");
 pref("browser.ping-centre.production.endpoint", "https://tiles.services.mozilla.com/v3/links/ping-centre");
 
 // Enable GMP support in the addon manager.
 pref("media.gmp-provider.enabled", true);
 
 pref("browser.contentblocking.enabled", true);
+pref("browser.contentblocking.cookies-site-data.ui.reject-trackers.enabled", true);
 pref("browser.contentblocking.cookies-site-data.ui.reject-trackers.recommended", true);
 #ifdef NIGHTLY_BUILD
 pref("browser.contentblocking.ui.enabled", true);
 pref("browser.contentblocking.cookies-site-data.ui.enabled", true);
 #else
 pref("browser.contentblocking.ui.enabled", false);
 pref("browser.contentblocking.cookies-site-data.ui.enabled", false);
 #endif
--- a/browser/components/preferences/in-content/privacy.js
+++ b/browser/components/preferences/in-content/privacy.js
@@ -24,16 +24,19 @@ XPCOMUtils.defineLazyPreferenceGetter(th
                                       "browser.contentblocking.ui.enabled");
 
 XPCOMUtils.defineLazyPreferenceGetter(this, "contentBlockingCookiesAndSiteDataUiEnabled",
                                       "browser.contentblocking.cookies-site-data.ui.enabled");
 
 XPCOMUtils.defineLazyPreferenceGetter(this, "contentBlockingCookiesAndSiteDataRejectTrackersRecommended",
                                       "browser.contentblocking.cookies-site-data.ui.reject-trackers.recommended");
 
+XPCOMUtils.defineLazyPreferenceGetter(this, "contentBlockingCookiesAndSiteDataRejectTrackersEnabled",
+                                      "browser.contentblocking.cookies-site-data.ui.reject-trackers.enabled");
+
 XPCOMUtils.defineLazyPreferenceGetter(this, "contentBlockingEnabled",
                                       "browser.contentblocking.enabled");
 
 const PREF_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
 
 const TRACKING_PROTECTION_KEY = "websites.trackingProtectionMode";
 const TRACKING_PROTECTION_PREFS = ["privacy.trackingprotection.enabled",
                                    "privacy.trackingprotection.pbmode.enabled"];
@@ -526,16 +529,20 @@ var gPrivacyPane = {
       keepUntil.classList.remove("indent"); // drop the indentation
       keepUntil.setAttribute("style", "margin-top: 1em"); // apply a margin
 
       // Allow turning off the "(recommended)" label using a pref
       let blockCookiesFromTrackers = document.getElementById("blockCookiesFromTrackers");
       if (contentBlockingCookiesAndSiteDataRejectTrackersRecommended) {
         document.l10n.setAttributes(blockCookiesFromTrackers, "sitedata-block-trackers-option-recommended");
       }
+      // Allow hiding the Reject Trackers option based on a pref
+      if (!contentBlockingCookiesAndSiteDataRejectTrackersEnabled) {
+        blockCookiesFromTrackers.remove();
+      }
     }
   },
 
   /**
    * Updates the preferences UI to reflect the browser.contentblocking.enabled pref.
    * This affects the button to toggle the pref and the disabled state of the dependent controls.
    */
   updateContentBlockingToggle() {
--- a/browser/components/preferences/in-content/tests/browser.ini
+++ b/browser/components/preferences/in-content/tests/browser.ini
@@ -66,16 +66,17 @@ skip-if = e10s
 [browser_privacypane.js]
 run-if = nightly_build
 # browser_privacypane.js only has Browser Error collection tests currently,
 # which is disabled outside Nightly. Remove this once non-Nightly tests are
 # added.
 [browser_privacypane_1.js]
 [browser_privacypane_2.js]
 [browser_privacypane_3.js]
+[browser_privacypane_4.js]
 [browser_privacypane_5.js]
 [browser_sanitizeOnShutdown_prefLocked.js]
 [browser_searchShowSuggestionsFirst.js]
 [browser_searchsuggestions.js]
 [browser_security-1.js]
 [browser_security-2.js]
 [browser_spotlight.js]
 [browser_site_login_exceptions.js]
--- a/browser/components/preferences/in-content/tests/browser_privacypane_2.js
+++ b/browser/components/preferences/in-content/tests/browser_privacypane_2.js
@@ -3,17 +3,18 @@ let jar = getJar(rootDir);
 if (jar) {
   let tmpdir = extractJarToTmp(jar);
   rootDir = "file://" + tmpdir.path + "/";
 }
 /* import-globals-from privacypane_tests_perwindow.js */
 Services.scriptloader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
 
 SpecialPowers.pushPrefEnv({"set":
-  [["browser.contentblocking.cookies-site-data.ui.enabled", true]]
+  [["browser.contentblocking.cookies-site-data.ui.enabled", true],
+   ["browser.contentblocking.cookies-site-data.ui.reject-trackers.enabled", true]]
 });
 
 run_test_subset([
   test_pane_visibility,
   test_dependent_elements,
   test_dependent_cookie_elements,
   test_dependent_clearonclose_elements,
   test_dependent_prefs,
new file mode 100644
--- /dev/null
+++ b/browser/components/preferences/in-content/tests/browser_privacypane_4.js
@@ -0,0 +1,21 @@
+let rootDir = getRootDirectory(gTestPath);
+let jar = getJar(rootDir);
+if (jar) {
+  let tmpdir = extractJarToTmp(jar);
+  rootDir = "file://" + tmpdir.path + "/";
+}
+/* import-globals-from privacypane_tests_perwindow.js */
+Services.scriptloader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
+
+SpecialPowers.pushPrefEnv({"set":
+  [["browser.contentblocking.cookies-site-data.ui.enabled", true],
+   ["browser.contentblocking.cookies-site-data.ui.reject-trackers.enabled", false]]
+});
+
+run_test_subset([
+  test_pane_visibility,
+  test_dependent_elements,
+  test_dependent_cookie_elements,
+  test_dependent_clearonclose_elements,
+  test_dependent_prefs,
+]);
--- a/browser/components/preferences/in-content/tests/privacypane_tests_perwindow.js
+++ b/browser/components/preferences/in-content/tests/privacypane_tests_perwindow.js
@@ -158,17 +158,21 @@ function test_dependent_cookie_elements(
     expect_disabled(true, [blockCookiesLabel, blockCookiesMenu]);
     expect_disabled(false, [keepUntil, keepCookiesUntil]);
 
     blockCookiesMenu.value = "always";
     controlChanged(blockCookiesMenu);
     expect_disabled(true, [keepUntil, keepCookiesUntil]);
     expect_disabled(false, [blockCookiesLabel, blockCookiesMenu]);
 
-    blockCookiesMenu.value = "trackers";
+    if (win.contentBlockingCookiesAndSiteDataRejectTrackersEnabled) {
+      blockCookiesMenu.value = "trackers";
+    } else {
+      blockCookiesMenu.value = "unvisited";
+    }
     controlChanged(blockCookiesMenu);
     expect_disabled(false);
   } else {
     acceptcookies.value = "2";
     controlChanged(acceptcookies);
     expect_disabled(true);
 
     acceptcookies.value = "1";