OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <script src="../../../resources/testharness.js"></script> |
3 <head> | 3 <script src="../../../resources/testharnessreport.js"></script> |
4 <script src="../../../resources/js-test.js"></script> | |
5 <script src="resources/shadow-dom.js"></script> | |
6 </head> | |
7 <body> | |
8 <p id="description"></p> | |
9 <div id="sandbox"></div> | |
10 <pre id="console"></pre> | |
11 <div id='a'> | 4 <div id='a'> |
12 <div id='b'> | 5 <div id='b'> |
13 <div id='c'> | 6 <div id='c'> |
14 </div> | 7 </div> |
15 </div> | 8 </div> |
16 </div> | 9 </div> |
17 <script> | 10 <script> |
18 var b = document.getElementById('b'); | 11 var b = document.getElementById('b'); |
19 b.addEventListener('click', function(event) { | 12 b.addEventListener('click', function(event) { |
20 var path = event.path; | 13 var path = event.path; |
21 debug(dumpNodeList(path)); | 14 test(function () { |
22 debug('Makes sure that event.path returns static NodeList.'); | 15 assert_event_path_for_b(path); |
| 16 }, "event.path in click event"); |
23 path[1] = ''; | 17 path[1] = ''; |
24 debug(dumpNodeList(event.path)); | 18 test(function () { |
| 19 assert_event_path_for_b(event.path); |
| 20 }, "Make sure that event.path returns static NodeList."); |
25 }); | 21 }); |
26 var clickEvent = document.createEvent("MouseEvents"); | 22 var clickEvent = document.createEvent("MouseEvents"); |
27 debug("Makes sure that event.path is empty before dispatching the event."); | 23 test(function () { |
28 debug(dumpNodeList(clickEvent.path)); | 24 assert_equals(clickEvent.path.length, 0); |
| 25 }, "Make sure that event.path is empty before dispatching the event."); |
| 26 |
29 clickEvent.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, fa
lse, false, false, 0, null); | 27 clickEvent.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, fa
lse, false, false, 0, null); |
30 b.dispatchEvent(clickEvent); | 28 b.dispatchEvent(clickEvent); |
31 debug("Makes sure that event.path isn't emptified after dispatching the event.")
; | 29 |
32 debug(dumpNodeList(clickEvent.path)); | 30 function assert_event_path_for_b(path) { |
| 31 assert_equals(path.length, 6); |
| 32 assert_equals(path[0], b); |
| 33 assert_equals(path[1], a); |
| 34 assert_equals(path[2], document.body); |
| 35 assert_equals(path[3], document.documentElement); |
| 36 assert_equals(path[4], document); |
| 37 assert_equals(path[5], window); |
| 38 } |
| 39 |
| 40 test(function () { |
| 41 assert_event_path_for_b(clickEvent.path); |
| 42 }, "Make sure that event.path isn't emptified after dispatching the event."); |
33 </script> | 43 </script> |
34 </body> | |
35 </html> | |
OLD | NEW |