|
1 <html xmlns="http://www.w3.org/1999/xhtml"> |
|
2 <!-- |
|
3 https://bugzilla.mozilla.org/show_bug.cgi?id=403162 |
|
4 --> |
|
5 <head> |
|
6 <title>Test for Bug 403162</title> |
|
7 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
9 <bindings xmlns="http://www.mozilla.org/xbl"> |
|
10 <binding id="test"> |
|
11 <handlers> |
|
12 <handler event="foo" action="XPCNativeWrapper.unwrap(window).triggerCount++" allowuntrusted="true"/> |
|
13 </handlers> |
|
14 </binding> |
|
15 </bindings> |
|
16 </head> |
|
17 <body> |
|
18 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=403162">Mozilla Bug 403162</a> |
|
19 <p id="display" style="-moz-binding: url(#test)"></p> |
|
20 <div id="content" style="display: none"> |
|
21 |
|
22 </div> |
|
23 <pre id="test"> |
|
24 <script class="testbody" type="text/javascript"> |
|
25 <![CDATA[ |
|
26 var triggerCount = 0; |
|
27 |
|
28 function dispatchEvent(t) { |
|
29 var ev = document.createEvent("Events"); |
|
30 ev.initEvent("foo", true, true); |
|
31 t.dispatchEvent(ev); |
|
32 } |
|
33 |
|
34 /** Test for Bug 403162 **/ |
|
35 SimpleTest.waitForExplicitFinish(); |
|
36 addLoadEvent(function() { |
|
37 var t = $("display"); |
|
38 is(triggerCount, 0, "Haven't dispatched event"); |
|
39 |
|
40 dispatchEvent(t); |
|
41 is(triggerCount, 1, "Dispatched once"); |
|
42 |
|
43 dispatchEvent(t); |
|
44 is(triggerCount, 2, "Dispatched twice"); |
|
45 |
|
46 t.parentNode.removeChild(t); |
|
47 dispatchEvent(t); |
|
48 is(triggerCount, 2, "Listener should be gone now"); |
|
49 |
|
50 SimpleTest.finish(); |
|
51 }); |
|
52 ]]> |
|
53 </script> |
|
54 </pre> |
|
55 </body> |
|
56 </html> |
|
57 |