OLD | NEW |
| (Empty) |
1 <!doctype html> | |
2 <title>Event propagation tests</title> | |
3 <link rel=author title="Aryeh Gregor" href=ayg@aryeh.name> | |
4 <div id=log></div> | |
5 <script src=../../../../resources/testharness.js></script> | |
6 <script src=../../../../resources/testharnessreport.js></script> | |
7 <script> | |
8 "use strict"; | |
9 | |
10 function testPropagationFlag(ev, expected, desc) { | |
11 test(function() { | |
12 var called = false; | |
13 var callback = function() { called = true }; | |
14 document.head.addEventListener("foo", callback); | |
15 document.head.dispatchEvent(ev); | |
16 // Gecko resets the flags after dispatching; it will happily dispatch | |
17 // the event the second time around. | |
18 document.head.dispatchEvent(ev); | |
19 assert_equals(called, expected, "Propagation flag"); | |
20 document.head.removeEventListener("foo", callback); | |
21 }, desc); | |
22 } | |
23 | |
24 var ev = document.createEvent("Event"); | |
25 ev.initEvent("foo", true, false); | |
26 testPropagationFlag(ev, true, "Newly-created Event"); | |
27 ev.stopPropagation(); | |
28 testPropagationFlag(ev, false, "After stopPropagation()"); | |
29 ev.initEvent("foo", true, false); | |
30 testPropagationFlag(ev, true, "Reinitialized after stopPropagation()"); | |
31 | |
32 var ev = document.createEvent("Event"); | |
33 ev.initEvent("foo", true, false); | |
34 ev.stopImmediatePropagation(); | |
35 testPropagationFlag(ev, false, "After stopImmediatePropagation()"); | |
36 ev.initEvent("foo", true, false); | |
37 testPropagationFlag(ev, true, "Reinitialized after stopImmediatePropagation()"); | |
38 </script> | |
OLD | NEW |