dom/xbl/test/test_bug403162.xhtml

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/xbl/test/test_bug403162.xhtml	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,57 @@
     1.4 +<html xmlns="http://www.w3.org/1999/xhtml">
     1.5 +<!--
     1.6 +https://bugzilla.mozilla.org/show_bug.cgi?id=403162
     1.7 +-->
     1.8 +<head>
     1.9 +  <title>Test for Bug 403162</title>
    1.10 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.11 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.12 +  <bindings xmlns="http://www.mozilla.org/xbl">
    1.13 +    <binding id="test">
    1.14 +      <handlers>
    1.15 +        <handler event="foo" action="XPCNativeWrapper.unwrap(window).triggerCount++" allowuntrusted="true"/>
    1.16 +      </handlers>
    1.17 +    </binding>
    1.18 +  </bindings>
    1.19 +</head>
    1.20 +<body>
    1.21 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=403162">Mozilla Bug 403162</a>
    1.22 +<p id="display" style="-moz-binding: url(#test)"></p>
    1.23 +<div id="content" style="display: none">
    1.24 +  
    1.25 +</div>
    1.26 +<pre id="test">
    1.27 +<script class="testbody" type="text/javascript">
    1.28 +<![CDATA[
    1.29 +var triggerCount = 0;
    1.30 +
    1.31 +function dispatchEvent(t) {
    1.32 +  var ev = document.createEvent("Events");
    1.33 +  ev.initEvent("foo", true, true);
    1.34 +  t.dispatchEvent(ev);  
    1.35 +}
    1.36 +
    1.37 +/** Test for Bug 403162 **/
    1.38 +SimpleTest.waitForExplicitFinish();
    1.39 +addLoadEvent(function() {
    1.40 +  var t = $("display");
    1.41 +  is(triggerCount, 0, "Haven't dispatched event");
    1.42 +
    1.43 +  dispatchEvent(t);
    1.44 +  is(triggerCount, 1, "Dispatched once");
    1.45 +
    1.46 +  dispatchEvent(t);
    1.47 +  is(triggerCount, 2, "Dispatched twice");
    1.48 +
    1.49 +  t.parentNode.removeChild(t);
    1.50 +  dispatchEvent(t);
    1.51 +  is(triggerCount, 2, "Listener should be gone now");
    1.52 +
    1.53 +  SimpleTest.finish();
    1.54 +});
    1.55 +]]>
    1.56 +</script>
    1.57 +</pre>
    1.58 +</body>
    1.59 +</html>
    1.60 +

mercurial