Bug 1540416 - Correctly test cookie restrictions in browser_trackingUI_report_breakage. r=ewright
authorJohann Hofmann <jhofmann@mozilla.com>
Mon, 15 Apr 2019 18:53:22 +0000
changeset 469563 5e0cf8b42fcf
parent 469562 2c2b6f2cb293
child 469564 7d26d6d473cf
push id35874
push userccoroiu@mozilla.com
push dateTue, 16 Apr 2019 04:04:58 +0000
treeherdermozilla-central@be3f40425b52 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersewright
bugs1540416
milestone68.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 1540416 - Correctly test cookie restrictions in browser_trackingUI_report_breakage. r=ewright Differential Revision: https://phabricator.services.mozilla.com/D27255
browser/base/content/test/trackingUI/browser_trackingUI_report_breakage.js
--- a/browser/base/content/test/trackingUI/browser_trackingUI_report_breakage.js
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_report_breakage.js
@@ -5,16 +5,17 @@
 
 const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html";
 const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/benignPage.html";
 const COOKIE_PAGE = "http://not-tracking.example.com/browser/browser/base/content/test/trackingUI/cookiePage.html";
 
 const CM_PREF = "privacy.trackingprotection.cryptomining.enabled";
 const FP_PREF = "privacy.trackingprotection.fingerprinting.enabled";
 const TP_PREF = "privacy.trackingprotection.enabled";
+const CB_PREF = "network.cookie.cookieBehavior";
 
 const PREF_REPORT_BREAKAGE_ENABLED = "browser.contentblocking.reportBreakage.enabled";
 const PREF_REPORT_BREAKAGE_URL = "browser.contentblocking.reportBreakage.url";
 
 let {HttpServer} = ChromeUtils.import("resource://testing-common/httpd.js");
 let {CommonUtils} = ChromeUtils.import("resource://services-common/utils.js");
 let {Preferences} = ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
@@ -24,16 +25,17 @@ add_task(async function setup() {
   let oldCanRecord = Services.telemetry.canRecordExtended;
   Services.telemetry.canRecordExtended = true;
 
   registerCleanupFunction(() => {
     Services.telemetry.canRecordExtended = oldCanRecord;
 
     // Clear prefs that are touched in this test again for sanity.
     Services.prefs.clearUserPref(TP_PREF);
+    Services.prefs.clearUserPref(CB_PREF);
     Services.prefs.clearUserPref(FP_PREF);
     Services.prefs.clearUserPref(CM_PREF);
     Services.prefs.clearUserPref(PREF_REPORT_BREAKAGE_ENABLED);
     Services.prefs.clearUserPref(PREF_REPORT_BREAKAGE_URL);
 
     UrlClassifierTestUtils.cleanupTestTrackers();
   });
 
@@ -162,46 +164,59 @@ add_task(async function testTP() {
   let url = TRACKING_PAGE + "?a=b&1=abc&unicode=🦊";
   await BrowserTestUtils.withNewTab(url, async function() {
     await testReportBreakage(TRACKING_PAGE, "trackingprotection");
   });
 
   Services.prefs.clearUserPref(TP_PREF);
 });
 
+add_task(async function testCR() {
+  Services.prefs.setIntPref(CB_PREF, Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER);
+  // Make sure that we correctly strip the query.
+  let url = COOKIE_PAGE + "?a=b&1=abc&unicode=🦊";
+  await BrowserTestUtils.withNewTab(url, async function() {
+    await testReportBreakage(COOKIE_PAGE, "cookierestrictions");
+  });
+
+  Services.prefs.clearUserPref(CB_PREF);
+});
+
 add_task(async function testFP() {
+  Services.prefs.setIntPref(CB_PREF, Ci.nsICookieService.BEHAVIOR_ACCEPT);
   Services.prefs.setBoolPref(FP_PREF, true);
   // Make sure that we correctly strip the query.
   let url = TRACKING_PAGE + "?a=b&1=abc&unicode=🦊";
   await BrowserTestUtils.withNewTab(url, async function(browser) {
     await ContentTask.spawn(browser, {}, function() {
       content.postMessage("fingerprinting", "*");
     });
 
-    // Without TP, we will have a cookie restrictions entry for trackertest.org.
-    await testReportBreakage(TRACKING_PAGE, "cookierestrictions,fingerprinting");
+    await testReportBreakage(TRACKING_PAGE, "fingerprinting");
   });
 
   Services.prefs.clearUserPref(FP_PREF);
+  Services.prefs.clearUserPref(CB_PREF);
 });
 
 add_task(async function testCM() {
+  Services.prefs.setIntPref(CB_PREF, Ci.nsICookieService.BEHAVIOR_ACCEPT);
   Services.prefs.setBoolPref(CM_PREF, true);
   // Make sure that we correctly strip the query.
   let url = TRACKING_PAGE + "?a=b&1=abc&unicode=🦊";
   await BrowserTestUtils.withNewTab(url, async function(browser) {
     await ContentTask.spawn(browser, {}, function() {
       content.postMessage("cryptomining", "*");
     });
 
-    // Without TP, we will have a cookie restrictions entry for trackertest.org.
-    await testReportBreakage(TRACKING_PAGE, "cookierestrictions,cryptomining");
+    await testReportBreakage(TRACKING_PAGE, "cryptomining");
   });
 
   Services.prefs.clearUserPref(CM_PREF);
+  Services.prefs.clearUserPref(CB_PREF);
 });
 
 async function testReportBreakage(url, tags) {
   // Setup a mock server for receiving breakage reports.
   let server = new HttpServer();
   server.start(-1);
   let i = server.identity;
   let path = i.primaryScheme + "://" + i.primaryHost + ":" + i.primaryPort + "/";
@@ -253,17 +268,17 @@ async function testReportBreakage(url, t
       let prefsBody = "";
 
       for (let pref of prefs) {
         prefsBody += `${pref}: ${Preferences.get(pref)}\r\n`;
       }
 
       Assert.deepEqual(sections, [
         "",
-        "Content-Disposition: form-data; name=\"title\"\r\n\r\ntracking.example.org\r\n",
+        `Content-Disposition: form-data; name=\"title\"\r\n\r\n${Services.io.newURI(reportURL).host}\r\n`,
         "Content-Disposition: form-data; name=\"body\"\r\n\r\n" +
         `Full URL: ${reportURL + "?"}\r\n` +
         `userAgent: ${navigator.userAgent}\r\n\r\n` +
         "**Preferences**\r\n" +
         `${prefsBody}\r\n` +
         "**Comments**\r\n" +
         "This is a comment\r\n",
         "Content-Disposition: form-data; name=\"labels\"\r\n\r\n" +