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