summaryrefslogtreecommitdiffstats
path: root/browser/components/resistfingerprinting/test/mochitest/test_device_sensor_event.html
blob: 7ec4dce94f51801e33cfd0369fad840f6dc6b1bc (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
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1369319
-->
<head>
  <meta charset="utf-8">
  <title>Test for Bug 1369319</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  <script type="application/javascript">

  /** Test for Bug 1369319 */
  SimpleTest.waitForExplicitFinish();
  window.onload = () => {
    SimpleTest.waitForFocus(() => {
      SpecialPowers.pushPrefEnv({"set":
        [
          ["device.sensors.test.events", true],
          ["privacy.resistFingerprinting", true],
        ],
      }, doTest);
    }, window);
  };

  function doTest() {
    window.addEventListener("devicemotion", () => {
      ok(false, "The device motion event should not be fired.");
    }, {once: true});

    window.addEventListener("TestEvent", () => {
      // If we receive this event without receiving a 'devicemotion' event, this means
      // the device sensor event has been blocked correctly.
      ok(true, "Got the 'TestEvent' event.");
      SimpleTest.finish();
    }, {once: true});

    window.dispatchEvent(new CustomEvent("TestEvent"));
  }
  </script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<p id="display"></p>
<div id="content" style="display: none">

</div>
<pre id="test"></pre>
</body>
</html>