Event-dispatch-order.html (921B)
1 <!DOCTYPE html> 2 <title>Event phases order</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <div id="log"></div> 6 <script> 7 async_test(function() { 8 document.addEventListener('DOMContentLoaded', this.step_func_done(function() { 9 var parent = document.getElementById('parent'); 10 var child = document.getElementById('child'); 11 12 var order = []; 13 14 parent.addEventListener('click', this.step_func(function(){ order.push(1) }), true); 15 child.addEventListener('click', this.step_func(function(){ order.push(2) }), false); 16 parent.addEventListener('click', this.step_func(function(){ order.push(3) }), false); 17 18 child.dispatchEvent(new Event('click', {bubbles: true})); 19 20 assert_array_equals(order, [1, 2, 3]); 21 })); 22 }, "Event phases order"); 23 </script> 24 <div id="parent"> 25 <div id="child"></div> 26 </div>