11cb0ef41Sopenharmony_ci<!DOCTYPE html>
21cb0ef41Sopenharmony_ci<html>
31cb0ef41Sopenharmony_ci<head>
41cb0ef41Sopenharmony_ci<title>Multiple dispatchEvent() and cancelBubble</title>
51cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script>
61cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script>
71cb0ef41Sopenharmony_ci</head>
81cb0ef41Sopenharmony_ci<body>
91cb0ef41Sopenharmony_ci<div id=log></div>
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ci<div id="parent" style="display: none">
121cb0ef41Sopenharmony_ci    <input id="target" type="hidden" value=""/>
131cb0ef41Sopenharmony_ci</div>
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci<script>
161cb0ef41Sopenharmony_citest(function() {
171cb0ef41Sopenharmony_ci    var event_type = "foo";
181cb0ef41Sopenharmony_ci    var target = document.getElementById("target");
191cb0ef41Sopenharmony_ci    var parent = document.getElementById("parent");
201cb0ef41Sopenharmony_ci    var actual_result;
211cb0ef41Sopenharmony_ci    var test_event = function(evt) {
221cb0ef41Sopenharmony_ci        actual_result.push(evt.currentTarget);
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ci        if (parent == evt.currentTarget) {
251cb0ef41Sopenharmony_ci            evt.cancelBubble = true;
261cb0ef41Sopenharmony_ci        }
271cb0ef41Sopenharmony_ci    };
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci    var evt = document.createEvent("Event");
301cb0ef41Sopenharmony_ci    evt.initEvent(event_type, true, true);
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ci    target.addEventListener(event_type, test_event, false);
331cb0ef41Sopenharmony_ci    parent.addEventListener(event_type, test_event, false);
341cb0ef41Sopenharmony_ci    document.addEventListener(event_type, test_event, false);
351cb0ef41Sopenharmony_ci    window.addEventListener(event_type, test_event, false);
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_ci    actual_result = [];
381cb0ef41Sopenharmony_ci    target.dispatchEvent(evt);
391cb0ef41Sopenharmony_ci    assert_array_equals(actual_result, [target, parent]);
401cb0ef41Sopenharmony_ci
411cb0ef41Sopenharmony_ci    actual_result = [];
421cb0ef41Sopenharmony_ci    parent.dispatchEvent(evt);
431cb0ef41Sopenharmony_ci    assert_array_equals(actual_result, [parent]);
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_ci    actual_result = [];
461cb0ef41Sopenharmony_ci    document.dispatchEvent(evt);
471cb0ef41Sopenharmony_ci    assert_array_equals(actual_result, [document, window]);
481cb0ef41Sopenharmony_ci});
491cb0ef41Sopenharmony_ci</script>
501cb0ef41Sopenharmony_ci</body>
511cb0ef41Sopenharmony_ci</html>
52