Bug 1506947 - Part 2: Add a test for the site-specific workaround pref; r=baku
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 15 Nov 2018 00:16:17 -0500
changeset 503870 9d063d43285132a0fb2d3e258b7027d3cb9e39bd
parent 503869 306c9aaac8cd1395a17788385cc10997d46b8f2d
child 503871 0a141aec9e3a5d5a2f42937ac24d14022ef7833c
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1506947
milestone65.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 1506947 - Part 2: Add a test for the site-specific workaround pref; r=baku Differential Revision: https://phabricator.services.mozilla.com/D11980
toolkit/components/antitracking/test/browser/browser.ini
toolkit/components/antitracking/test/browser/browser_siteSpecificWorkArounds.js
--- a/toolkit/components/antitracking/test/browser/browser.ini
+++ b/toolkit/components/antitracking/test/browser/browser.ini
@@ -39,16 +39,17 @@ skip-if = (os == "win" && os_version == 
 [browser_imageCache4-2.js]
 [browser_imageCache8.js]
 [browser_onBeforeRequestNotificationForTrackingResources.js]
 [browser_onModifyRequestNotificationForTrackingResources.js]
 [browser_permissionInNormalWindows.js]
 skip-if = serviceworker_e10s
 [browser_permissionInPrivateWindows.js]
 skip-if = serviceworker_e10s
+[browser_siteSpecificWorkArounds.js]
 [browser_subResources.js]
 skip-if = serviceworker_e10s
 support-files = subResources.sjs
 [browser_script.js]
 support-files = tracker.js
 [browser_userInteraction.js]
 [browser_storageAccessPrivateWindow.js]
 skip-if = serviceworker_e10s
new file mode 100644
--- /dev/null
+++ b/toolkit/components/antitracking/test/browser/browser_siteSpecificWorkArounds.js
@@ -0,0 +1,65 @@
+AntiTracking.runTest("localStorage with a tracker that is whitelisted via a pref",
+  async _ => {
+    localStorage.foo = 42;
+    ok(true, "LocalStorage is allowed");
+  },
+  async _ => {
+    localStorage.foo = 42;
+    ok(true, "LocalStorage is allowed");
+  },
+  async _ => {
+    await new Promise(resolve => {
+      Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
+    });
+  },
+  [["urlclassifier.trackingAnnotationSkipURLs", "tracking.example.org"]],
+  false, // run the window.open() test
+  false, // run the user interaction test
+  0, // don't expect blocking notifications
+  false); // run in a normal window
+
+AntiTracking.runTest("localStorage with a tracker that is whitelisted via a fancy pref",
+  async _ => {
+    localStorage.foo = 42;
+    ok(true, "LocalStorage is allowed");
+  },
+  async _ => {
+    localStorage.foo = 42;
+    ok(true, "LocalStorage is allowed");
+  },
+  async _ => {
+    await new Promise(resolve => {
+      Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
+    });
+  },
+  [["urlclassifier.trackingAnnotationSkipURLs", "foobar.example,*.example.org,baz.example"]],
+  false, // run the window.open() test
+  false, // run the user interaction test
+  0, // don't expect blocking notifications
+  false); // run in a normal window
+
+AntiTracking.runTest("localStorage with a tracker that is whitelisted via a misconfigured pref",
+  async _ => {
+    try {
+      localStorage.foo = 42;
+      ok(false, "LocalStorage cannot be used!");
+    } catch (e) {
+      ok(true, "LocalStorage cannot be used!");
+      is(e.name, "SecurityError", "We want a security error message.");
+    }
+  },
+  async _ => {
+    localStorage.foo = 42;
+    ok(true, "LocalStorage is allowed");
+  },
+  async _ => {
+    await new Promise(resolve => {
+      Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
+    });
+  },
+  [["urlclassifier.trackingAnnotationSkipURLs", "*.tracking.example.org"]],
+  false, // run the window.open() test
+  false, // run the user interaction test
+  Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_TRACKER, // expect blocking notifications
+  false); // run in a normal window
+