Bug 1461921 - Block storage access for third-parties on the tracking protection list - part 4 - ServiceWorkers, r=ehsan
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 20 Jun 2018 13:38:22 -0400
changeset 423171 c34c37fe5f9dacb1c0be20542823597c1e8f32a1
parent 423170 c9c37c6ca4373aa7f6ac637a849674e503ae30e5
child 423172 a8b4f415c04375d1bf0420cf06690ffecf2b8d3f
push id34164
push usercsabou@mozilla.com
push dateThu, 21 Jun 2018 01:17:13 +0000
treeherdermozilla-central@d231a3231680 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1461921
milestone62.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 1461921 - Block storage access for third-parties on the tracking protection list - part 4 - ServiceWorkers, r=ehsan
toolkit/components/antitracking/test/browser/browser.ini
toolkit/components/antitracking/test/browser/browser_blockingResources.js
toolkit/components/antitracking/test/browser/empty.js
toolkit/components/antitracking/test/browser/head.js
--- a/toolkit/components/antitracking/test/browser/browser.ini
+++ b/toolkit/components/antitracking/test/browser/browser.ini
@@ -1,8 +1,9 @@
 [DEFAULT]
 support-files =
   head.js
   page.html
   3rdParty.html
+  empty.js
 
 [browser_blockingResources.js]
 [browser_blockingMessaging.js]
--- a/toolkit/components/antitracking/test/browser/browser_blockingResources.js
+++ b/toolkit/components/antitracking/test/browser/browser_blockingResources.js
@@ -97,8 +97,31 @@ AntiTracking.runTest("SharedWorkers",
       ok(true, "SharedWorker cannot be used!");
       is(e.name, "SecurityError", "We want a security error message.");
     }
   },
   async _ => {
     new SharedWorker("a.js", "foo");
     ok(true, "SharedWorker is allowed");
   });
+
+AntiTracking.runTest("ServiceWorkers",
+  async _ => {
+    await navigator.serviceWorker.register("empty.js", { scope: "/" }).then(
+      _ => { ok(false, "ServiceWorker cannot be used!"); },
+      _ => { ok(true, "ServiceWorker cannot be used!"); });
+  },
+  null,
+  [["dom.serviceWorkers.exemptFromPerDomainMax", true],
+   ["dom.serviceWorkers.enabled", true],
+   ["dom.serviceWorkers.testing.enabled", true]]);
+
+AntiTracking.runTest("DOM Cache",
+  async _ => {
+    await caches.open("wow").then(
+      _ => { ok(false, "DOM Cache cannot be used!"); },
+      _ => { ok(true, "DOM Cache cannot be used!"); });
+  },
+  async _ => {
+    await caches.open("wow").then(
+      _ => { ok(true, "DOM Cache can be used!"); },
+      _ => { ok(false, "DOM Cache can be used!"); });
+  });
new file mode 100644
--- /dev/null
+++ b/toolkit/components/antitracking/test/browser/empty.js
@@ -0,0 +1,1 @@
+/* nothing here */
--- a/toolkit/components/antitracking/test/browser/head.js
+++ b/toolkit/components/antitracking/test/browser/head.js
@@ -1,38 +1,42 @@
 const TEST_DOMAIN = "http://example.net/";
-const TEST_3RD_PARTY_DOMAIN = "http://tracking.example.com/";
+const TEST_3RD_PARTY_DOMAIN = "https://tracking.example.com/";
 
 const TEST_PATH = "browser/toolkit/components/antitracking/test/browser/";
 
 const TEST_TOP_PAGE = TEST_DOMAIN + TEST_PATH + "page.html";
 const TEST_3RD_PARTY_PAGE = TEST_3RD_PARTY_DOMAIN + TEST_PATH + "3rdParty.html";
 
 let {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm", {});
 
 this.AntiTracking = {
-  runTest(name, callbackTracking, callbackNonTracking) {
-    this._createTask(name, true, callbackTracking);
+  runTest(name, callbackTracking, callbackNonTracking, extraPrefs) {
+    this._createTask(name, true, callbackTracking, extraPrefs);
     if (callbackNonTracking) {
       this._createTask(name, false, callbackNonTracking);
     }
   },
 
-  _createTask(name, blocking, callback) {
+  _createTask(name, blocking, callback, extraPrefs) {
     add_task(async function() {
       info("Starting " + (blocking ? "blocking" : "non-blocking") + " test " + name);
 
       await SpecialPowers.flushPrefEnv();
       await SpecialPowers.pushPrefEnv({"set": [
         ["privacy.trackingprotection.storagerestriction.enabled", blocking],
         ["privacy.trackingprotection.enabled", false],
         ["privacy.trackingprotection.pbmode.enabled", false],
         ["privacy.trackingprotection.annotate_channels", blocking],
       ]});
 
+      if (extraPrefs && Array.isArray(extraPrefs) && extraPrefs.length) {
+       await SpecialPowers.pushPrefEnv({"set": extraPrefs });
+      }
+
       await UrlClassifierTestUtils.addTestTrackers();
 
       info("Creating a new tab");
       let tab = BrowserTestUtils.addTab(gBrowser, TEST_TOP_PAGE);
       gBrowser.selectedTab = tab;
 
       let browser = gBrowser.getBrowserForTab(tab);
       await BrowserTestUtils.browserLoaded(browser);