OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title>Multiple dispatchEvent() and cancelBubble</title> |
| 5 <script src="/resources/testharness.js"></script> |
| 6 <script src="/resources/testharnessreport.js"></script> |
| 7 </head> |
| 8 <body> |
| 9 <div id=log></div> |
| 10 |
| 11 <div id="parent" style="display: none"> |
| 12 <input id="target" type="hidden" value=""/> |
| 13 </div> |
| 14 |
| 15 <script> |
| 16 test(function() { |
| 17 var event_type = "foo"; |
| 18 var target = document.getElementById("target"); |
| 19 var parent = document.getElementById("parent"); |
| 20 var actual_result; |
| 21 var test_event = function(evt) { |
| 22 actual_result.push(evt.currentTarget); |
| 23 |
| 24 if (parent == evt.currentTarget) { |
| 25 evt.cancelBubble = true; |
| 26 } |
| 27 }; |
| 28 |
| 29 var evt = document.createEvent("Event"); |
| 30 evt.initEvent(event_type, true, true); |
| 31 |
| 32 target.addEventListener(event_type, test_event, false); |
| 33 parent.addEventListener(event_type, test_event, false); |
| 34 document.addEventListener(event_type, test_event, false); |
| 35 window.addEventListener(event_type, test_event, false); |
| 36 |
| 37 actual_result = []; |
| 38 target.dispatchEvent(evt); |
| 39 assert_array_equals(actual_result, [target, parent]); |
| 40 |
| 41 actual_result = []; |
| 42 parent.dispatchEvent(evt); |
| 43 assert_array_equals(actual_result, [parent]); |
| 44 |
| 45 actual_result = []; |
| 46 document.dispatchEvent(evt); |
| 47 assert_array_equals(actual_result, [document, window]); |
| 48 }); |
| 49 </script> |
| 50 </body> |
| 51 </html> |
OLD | NEW |