summaryrefslogtreecommitdiffstats
path: root/browser/components/resistfingerprinting/test/mochitest/test_bug863246_resource_uri.html
blob: fda1c0420072aeb03d57a3e28bc55052e684f2b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<meta charset="utf8">
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script>
/* global SimpleTest SpecialPowers add_task */

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 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>