dom/events/test/test_bug742376.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/events/test/test_bug742376.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,58 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=402089
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 742376</title>
    1.11 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.14 +</head>
    1.15 +
    1.16 +<body>
    1.17 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=742376">Mozilla Bug 742376</a>
    1.18 +<script class="testbody" type="text/javascript">
    1.19 +
    1.20 +/** Test for Bug 742376 **/
    1.21 +
    1.22 +function hasListeners() {
    1.23 +
    1.24 +  var Cc = SpecialPowers.Cc;
    1.25 +  var Ci = SpecialPowers.Ci;
    1.26 +  var dss = Cc["@mozilla.org/devicesensors;1"].getService(Ci.nsIDeviceSensors);
    1.27 +
    1.28 +  return dss.hasWindowListener(Ci.nsIDeviceSensorData.TYPE_ORIENTATION, window);
    1.29 +}
    1.30 +
    1.31 +is(hasListeners(), false, "Must not have listeners before tests start");
    1.32 +
    1.33 +function dumbListener(event) {}
    1.34 +function dumbListener2(event) {}
    1.35 +
    1.36 +window.addEventListener("deviceorientation", dumbListener, false);
    1.37 +window.addEventListener("deviceorientation", dumbListener2, false);
    1.38 +
    1.39 +is(hasListeners(), true, "Listeners should have been added");
    1.40 +
    1.41 +window.setTimeout(function() {
    1.42 +
    1.43 +  window.removeEventListener("deviceorientation", dumbListener, false);
    1.44 +  is(hasListeners(), true, "Only some listeners should have been removed");
    1.45 +  window.setTimeout(function() {
    1.46 +
    1.47 +    window.removeEventListener("deviceorientation", dumbListener2, false);
    1.48 +    window.setTimeout(function() {
    1.49 +      is(hasListeners(), false, "Listeners should have been removed");
    1.50 +      SimpleTest.finish();
    1.51 +    }, 0);
    1.52 +  }, 0);
    1.53 +}, 0);
    1.54 +
    1.55 +SimpleTest.waitForExplicitFinish();
    1.56 +
    1.57 +</script>
    1.58 +</pre>
    1.59 +</body>
    1.60 +</html>
    1.61 +

mercurial