summaryrefslogtreecommitdiffstats
path: root/dom/base/test/test_bug1281963.html
blob: b2d48cc7ecac20933f17ec05e2384c92ea13086a (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
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/1281963
-->
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <title>Test for Bug 1281963</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<div id="content"></div>

<script class="testbody" type="application/javascript">

let pushPref = function(key, value) {
  return SpecialPowers.pushPrefEnv({"set": [[key, value]]});
};

let popPref = function() {
  SpecialPowers.popPrefEnv();
};

// Run a test to see that we don't hide the hard-coded mimeTypes
// or plugins when "privacy.resistFingerprinting" is active.
// See bug 1756280.
add_task(async function() {
  for (let rfpEnabled of [true, false]) {
    await pushPref("privacy.resistFingerprinting", rfpEnabled);
    for (let pdfDisabled of [true, false]) {
      await pushPref("pdfjs.disabled", pdfDisabled);
      if (pdfDisabled && !rfpEnabled) {
        is(navigator.mimeTypes.length, 0, "navigator.mimeTypes.length should be 0");
        is(navigator.plugins.length, 0, "navigator.plugins.length should 0");
      } else {
        let exampleMimeType = navigator.mimeTypes[0];
        let examplePlugin = navigator.plugins[0];

        isnot(navigator.mimeTypes[exampleMimeType.type], undefined, "Should reveal mime type");
        is(navigator.mimeTypes.length, 2, "navigator.mimeTypes.length should be 2");

        isnot(navigator.plugins[examplePlugin.name], undefined, "Should reveal plugin");
        is(navigator.plugins.length, 5, "navigator.plugins.length should be nonzero");
      }
      await popPref();
    }
    await popPref();
  }
});

</script>

</body>
</html>