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