Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=402089
5 -->
6 <head>
7 <title>Test for Bug 742376</title>
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
11 </head>
13 <body>
14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=742376">Mozilla Bug 742376</a>
15 <script class="testbody" type="text/javascript">
17 /** Test for Bug 742376 **/
19 function hasListeners() {
21 var Cc = SpecialPowers.Cc;
22 var Ci = SpecialPowers.Ci;
23 var dss = Cc["@mozilla.org/devicesensors;1"].getService(Ci.nsIDeviceSensors);
25 return dss.hasWindowListener(Ci.nsIDeviceSensorData.TYPE_ORIENTATION, window);
26 }
28 is(hasListeners(), false, "Must not have listeners before tests start");
30 function dumbListener(event) {}
31 function dumbListener2(event) {}
33 window.addEventListener("deviceorientation", dumbListener, false);
34 window.addEventListener("deviceorientation", dumbListener2, false);
36 is(hasListeners(), true, "Listeners should have been added");
38 window.setTimeout(function() {
40 window.removeEventListener("deviceorientation", dumbListener, false);
41 is(hasListeners(), true, "Only some listeners should have been removed");
42 window.setTimeout(function() {
44 window.removeEventListener("deviceorientation", dumbListener2, false);
45 window.setTimeout(function() {
46 is(hasListeners(), false, "Listeners should have been removed");
47 SimpleTest.finish();
48 }, 0);
49 }, 0);
50 }, 0);
52 SimpleTest.waitForExplicitFinish();
54 </script>
55 </pre>
56 </body>
57 </html>