test_device_sensor_event.html (1400B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1369319 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 1369319</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 <script type="application/javascript"> 12 13 /** Test for Bug 1369319 */ 14 SimpleTest.waitForExplicitFinish(); 15 window.onload = () => { 16 SimpleTest.waitForFocus(() => { 17 SpecialPowers.pushPrefEnv({"set": 18 [ 19 ["device.sensors.test.events", true], 20 ["privacy.resistFingerprinting", true], 21 ], 22 }, doTest); 23 }, window); 24 }; 25 26 function doTest() { 27 window.addEventListener("devicemotion", () => { 28 ok(false, "The device motion event should not be fired."); 29 }, {once: true}); 30 31 window.addEventListener("TestEvent", () => { 32 // If we receive this event without receiving a 'devicemotion' event, this means 33 // the device sensor event has been blocked correctly. 34 ok(true, "Got the 'TestEvent' event."); 35 SimpleTest.finish(); 36 }, {once: true}); 37 38 window.dispatchEvent(new CustomEvent("TestEvent")); 39 } 40 </script> 41 </head> 42 <body> 43 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a> 44 <p id="display"></p> 45 <div id="content" style="display: none"> 46 47 </div> 48 <pre id="test"></pre> 49 </body> 50 </html>