Bug 1494145 - Reland bug 1491061 part 3 again (this time without the browser.contentblocking.rejecttrackers.ui.enabled pref) a=test-only
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 25 Sep 2018 23:13:09 -0400
changeset 490111 0b63e03cfae87795bc1f3b24fa46054d0a6b74f2
parent 490110 4abe7ddf533cd4d374b57872b77091535cf2fdf2
child 490112 7c608659a5efe64710a8334945213961289b7b81
push id9911
push usereakhgari@mozilla.com
push dateFri, 28 Sep 2018 21:37:18 +0000
treeherdermozilla-beta@7c608659a5ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstest-only
bugs1494145, 1491061
milestone63.0
Bug 1494145 - Reland bug 1491061 part 3 again (this time without the browser.contentblocking.rejecttrackers.ui.enabled pref) a=test-only
dom/indexedDB/test/test_third_party.html
dom/serviceworkers/test/test_third_party_iframes.html
dom/tests/mochitest/bugs/test_bug1171215.html
dom/tests/mochitest/general/storagePermissionsUtils.js
dom/tests/mochitest/localstorage/test_localStorageCookieSettings.html
dom/workers/test/test_sharedWorker_thirdparty.html
extensions/cookie/test/file_testcommon.js
extensions/cookie/test/unit/test_cookies_thirdparty.js
--- a/dom/indexedDB/test/test_third_party.html
+++ b/dom/indexedDB/test/test_third_party.html
@@ -57,17 +57,21 @@
     function setiframe() {
       let iframe = document.getElementById("iframe1");
 
       if (!testRunning) {
         testRunning = true;
         iframe.addEventListener("load", iframeLoaded);
       }
       SpecialPowers.pushPrefEnv({
-        "set": [["network.cookie.cookieBehavior", testData[testIndex].cookieBehavior]]
+        "set": [
+          ["browser.contentblocking.enabled", true],
+          ["browser.contentblocking.ui.enabled", true],
+          ["network.cookie.cookieBehavior", testData[testIndex].cookieBehavior],
+        ]
       }, () => {
         iframe.src = testData[testIndex].host + iframe1Path;
       });
       // SpecialPowers.setIntPref("network.cookie.cookieBehavior", testData[testIndex].cookieBehavior);
     }
 
     function messageListener(event) {
       // eslint-disable-next-line no-eval
--- a/dom/serviceworkers/test/test_third_party_iframes.html
+++ b/dom/serviceworkers/test/test_third_party_iframes.html
@@ -79,16 +79,18 @@ function runTest(aExpectedResponses) {
     responsesIndex++;
   };
 }
 
 // Verify that we can register and intercept a 3rd party iframe with
 // the given cookie policy.
 function testShouldIntercept(behavior, lifetime, done) {
   SpecialPowers.pushPrefEnv({"set": [
+      ["browser.contentblocking.enabled", true],
+      ["browser.contentblocking.ui.enabled", true],
       ["network.cookie.cookieBehavior", behavior],
       ["network.cookie.lifetimePolicy", lifetime],
   ]}, function() {
     runTest([{
       status: "ok"
     }, {
       status: "registrationdone",
       next: function() {
--- a/dom/tests/mochitest/bugs/test_bug1171215.html
+++ b/dom/tests/mochitest/bugs/test_bug1171215.html
@@ -22,18 +22,21 @@ https://bugzilla.mozilla.org/show_bug.cg
     document.cookie = "a=b";
 
     // Set a cookie in example.org so we can test that we can't read it in
     // third-party cases.
     f.contentWindow.location =
         "http://example.org/tests/dom/tests/mochitest/bugs/file_prime_cookie.html";
     waitForLoad().then(function() {
         // Cookies are set up, disallow third-party cookies and start the test.
-        SpecialPowers.pushPrefEnv({ set: [[ 'network.cookie.cookieBehavior', 1 ]] },
-                                  () => { continueTest(); });
+        SpecialPowers.pushPrefEnv({ set: [
+            ["browser.contentblocking.enabled", true],
+            ["browser.contentblocking.ui.enabled", true],
+            ["network.cookie.cookieBehavior", 1],
+          ]}, () => { continueTest(); });
     }).catch((e) => { ok(false, `Got exception: ${e}`) });
   }
 
   function waitForLoad() {
     return new Promise((resolve) => {
       window.addEventListener("message", function(msg) {
         info(`got message ${msg.data}`);
         resolve(msg.data);
--- a/dom/tests/mochitest/general/storagePermissionsUtils.js
+++ b/dom/tests/mochitest/general/storagePermissionsUtils.js
@@ -21,17 +21,21 @@ if (inFrame) {
   };
 } else {
   finishTest = function() {
     SimpleTest.finish();
   };
 }
 
 function setCookieBehavior(behavior) {
-  return SpecialPowers.pushPrefEnv({"set": [[kPrefName, behavior]]});
+  return SpecialPowers.pushPrefEnv({"set": [
+    ["browser.contentblocking.enabled", true],
+    ["browser.contentblocking.ui.enabled", true],
+    [kPrefName, behavior],
+  ]});
 }
 
 function runIFrame(url) {
   return new Promise((resolve, reject) => {
     function onMessage(e)  {
       if (e.data == "done") {
         resolve();
         window.removeEventListener('message', onMessage);
--- a/dom/tests/mochitest/localstorage/test_localStorageCookieSettings.html
+++ b/dom/tests/mochitest/localstorage/test_localStorageCookieSettings.html
@@ -10,18 +10,21 @@
 <body>
 <iframe></iframe>
 
 <script type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 // Set cookies behavior to "always reject".
-SpecialPowers.pushPrefEnv({"set": [["network.cookie.cookieBehavior", 2]]},
-                          test1);
+SpecialPowers.pushPrefEnv({"set": [
+  ["browser.contentblocking.enabled", true],
+  ["browser.contentblocking.ui.enabled", true],
+  ["network.cookie.cookieBehavior", 2],
+]}, test1);
 
 function test1() {
   try {
     localStorage.setItem("contentkey", "test-value");
     ok(false, "Setting localStorageItem should throw a security exception");
   }
   catch(ex) {
     is(ex.name, "SecurityError");
--- a/dom/workers/test/test_sharedWorker_thirdparty.html
+++ b/dom/workers/test/test_sharedWorker_thirdparty.html
@@ -42,16 +42,18 @@
     ]});
     let result = await testThirdPartyFrame('allowed');
     ok(result === 'allowed',
        'SharedWorker should be allowed when 3rd party iframes can access storage');
   });
 
   add_task(async function blocked() {
     await SpecialPowers.pushPrefEnv({ set: [
+      ["browser.contentblocking.enabled", true],
+      ["browser.contentblocking.ui.enabled", true],
       ["network.cookie.cookieBehavior", COOKIE_BEHAVIOR_REJECTFOREIGN]
     ]});
     let result = await testThirdPartyFrame('blocked');
     ok(result === 'blocked',
        'SharedWorker should not be allowed when 3rd party iframes are denied storage');
   });
 
   </script>
--- a/extensions/cookie/test/file_testcommon.js
+++ b/extensions/cookie/test/file_testcommon.js
@@ -8,17 +8,21 @@ var gPopup;
 var gScript;
 
 var gLoads = 0;
 
 function setupTest(uri, cookies, loads) {
   SimpleTest.waitForExplicitFinish();
 
   var prefSet = new Promise(resolve => {
-    SpecialPowers.pushPrefEnv({ set: [["network.cookie.cookieBehavior", 1]] }, resolve);
+    SpecialPowers.pushPrefEnv({ set: [
+      ["browser.contentblocking.enabled", true],
+      ["browser.contentblocking.ui.enabled", true],
+      ["network.cookie.cookieBehavior", 1],
+    ]}, resolve);
   });
 
   gScript = SpecialPowers.loadChromeScript(SCRIPT_URL);
   gExpectedCookies = cookies;
   gExpectedLoads = loads;
 
   // Listen for MessageEvents.
   window.addEventListener("message", messageReceiver);
--- a/extensions/cookie/test/unit/test_cookies_thirdparty.js
+++ b/extensions/cookie/test/unit/test_cookies_thirdparty.js
@@ -1,16 +1,20 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // test third party cookie blocking, for the cases:
 // 1) with null channel
 // 2) with channel, but with no docshell parent
 
 function run_test() {
+  // Set the needed content blocking prefs
+  Services.prefs.setBoolPref("browser.contentblocking.enabled", true);
+  Services.prefs.setBoolPref("browser.contentblocking.ui.enabled", true);
+
   // Create URIs and channels pointing to foo.com and bar.com.
   // We will use these to put foo.com into first and third party contexts.
   var spec1 = "http://foo.com/foo.html";
   var spec2 = "http://bar.com/bar.html";
   var uri1 = NetUtil.newURI(spec1);
   var uri2 = NetUtil.newURI(spec2);
   var channel1 = NetUtil.newChannel({uri: uri1, loadUsingSystemPrincipal: true});
   var channel2 = NetUtil.newChannel({uri: uri2, loadUsingSystemPrincipal: true});