dom/events/test/test_bug742376.html

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:a8fc762eeffe
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>
12
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">
16
17 /** Test for Bug 742376 **/
18
19 function hasListeners() {
20
21 var Cc = SpecialPowers.Cc;
22 var Ci = SpecialPowers.Ci;
23 var dss = Cc["@mozilla.org/devicesensors;1"].getService(Ci.nsIDeviceSensors);
24
25 return dss.hasWindowListener(Ci.nsIDeviceSensorData.TYPE_ORIENTATION, window);
26 }
27
28 is(hasListeners(), false, "Must not have listeners before tests start");
29
30 function dumbListener(event) {}
31 function dumbListener2(event) {}
32
33 window.addEventListener("deviceorientation", dumbListener, false);
34 window.addEventListener("deviceorientation", dumbListener2, false);
35
36 is(hasListeners(), true, "Listeners should have been added");
37
38 window.setTimeout(function() {
39
40 window.removeEventListener("deviceorientation", dumbListener, false);
41 is(hasListeners(), true, "Only some listeners should have been removed");
42 window.setTimeout(function() {
43
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);
51
52 SimpleTest.waitForExplicitFinish();
53
54 </script>
55 </pre>
56 </body>
57 </html>
58

mercurial