11cb0ef41Sopenharmony_ci<!DOCTYPE html>
21cb0ef41Sopenharmony_ci<title>Event phases order</title>
31cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script>
41cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script>
51cb0ef41Sopenharmony_ci<div id="log"></div>
61cb0ef41Sopenharmony_ci<script>
71cb0ef41Sopenharmony_ciasync_test(function() {
81cb0ef41Sopenharmony_ci    document.addEventListener('DOMContentLoaded', this.step_func_done(function() {
91cb0ef41Sopenharmony_ci        var parent = document.getElementById('parent');
101cb0ef41Sopenharmony_ci        var child = document.getElementById('child');
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ci        var order = [];
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ci        parent.addEventListener('click', this.step_func(function(){ order.push(1) }), true);
151cb0ef41Sopenharmony_ci        child.addEventListener('click', this.step_func(function(){ order.push(2) }), false);
161cb0ef41Sopenharmony_ci        parent.addEventListener('click', this.step_func(function(){ order.push(3) }), false);
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ci        child.dispatchEvent(new Event('click', {bubbles: true}));
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ci        assert_array_equals(order, [1, 2, 3]);
211cb0ef41Sopenharmony_ci    }));
221cb0ef41Sopenharmony_ci}, "Event phases order");
231cb0ef41Sopenharmony_ci</script>
241cb0ef41Sopenharmony_ci<div id="parent">
251cb0ef41Sopenharmony_ci    <div id="child"></div>
261cb0ef41Sopenharmony_ci</div>
27