<!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.composedPath();
test(function () {
assert_event_path_for_b(path);
}, "event.composedPath() in click event");
path[1] = '';
test(function () {
assert_event_path_for_b(event.composedPath());
}, "Make sure that event.composedPath() returns static NodeList.");
});
var clickEvent = document.createEvent("MouseEvents");
test(function () {
assert_equals(clickEvent.composedPath().length, 0);
}, "Make sure that event.composedPath() 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_equals(clickEvent.composedPath().length, 0);
}, "Make sure that event.composedPath() is emptified after dispatching the event.");
</script>