Bug 863246 - Add test cases r=billm draft
authorChung-Sheng Fu <cfu@mozilla.com>
Thu, 08 Jun 2017 17:54:41 +0800
changeset 654066 80346c2da1bf7ea484bfd37b08df910f7bd26bf4
parent 654065 56f3bd471a4e21f40a052d808d993c593bed96f3
child 728471 80bea20f1e6d04f3b7d8eeb9db5985b0abc497fe
push id76471
push userbmo:cfu@mozilla.com
push dateMon, 28 Aug 2017 08:30:33 +0000
reviewersbillm
bugs863246
milestone57.0a1
Bug 863246 - Add test cases r=billm MozReview-Commit-ID: 9oXWNOREemX
browser/components/resistfingerprinting/test/mochitest/mochitest.ini
browser/components/resistfingerprinting/test/mochitest/test_bug863246_resource_uri.html
--- a/browser/components/resistfingerprinting/test/mochitest/mochitest.ini
+++ b/browser/components/resistfingerprinting/test/mochitest/mochitest.ini
@@ -1,17 +1,19 @@
 [DEFAULT]
 tags = resistfingerprinting
+
 support-files =
   file_animation_api.html
   worker_child.js
   worker_grandchild.js
   !/dom/tests/mochitest/geolocation/network_geolocation.sjs
 
 [test_animation_api.html]
 [test_device_sensor_event.html]
 [test_geolocation.html]
 scheme = https
 [test_reduce_time_precision.html]
 [test_hide_gamepad_info.html]
 support-files = test_hide_gamepad_info_iframe.html
 [test_speech_synthesis.html]
 [test_bug1382499_touch_api.html]
+[test_bug863246_resource_uri.html]
new file mode 100644
--- /dev/null
+++ b/browser/components/resistfingerprinting/test/mochitest/test_bug863246_resource_uri.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<meta charset="utf8">
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<script src="/tests/SimpleTest/SpawnTask.js"></script>
+<script>
+/* global SimpleTest SpecialPowers add_task */
+
+function waitForDOMContentLoaded() {
+  return new Promise((aResolve) => {
+    document.addEventListener("DOMContentLoaded", aResolve);
+  });
+}
+
+function testResourceUri(aTest, aUri, aContentAccessible) {
+  return new Promise((aResolve) => {
+    let link = document.createElement("link");
+    link.rel = "stylesheet";
+    link.onload = () => {
+      SimpleTest.ok(aContentAccessible, aTest);
+      aResolve();
+    };
+    link.onerror = () => {
+      SimpleTest.ok(!aContentAccessible, aTest);
+      aResolve();
+    };
+    link.href = aUri;
+    document.head.appendChild(link);
+  });
+}
+
+add_task(async function() {
+  await waitForDOMContentLoaded();
+  await testResourceUri(
+      "resource://content-accessible is content-accessible",
+      "resource://content-accessible/viewsource.css",
+      true);
+  await testResourceUri(
+      "resource://gre-resources is not content-accessible",
+      "resource://gre-resources/html.css",
+      false);
+  await SpecialPowers.pushPrefEnv({
+    set: [
+      ["security.all_resource_uri_content_accessible", true]
+    ]
+  });
+  await testResourceUri(
+      "security.all_resource_uri_content_accessible = true, resource://gre-resources is now content-accessible",
+      "resource://gre-resources/html.css",
+      true);
+});
+</script>