11cb0ef41Sopenharmony_ci<!DOCTYPE html>
21cb0ef41Sopenharmony_ci<meta charset=utf-8>
31cb0ef41Sopenharmony_ci<title> Determined event propagation path - target moved </title>
41cb0ef41Sopenharmony_ci<link rel="help" href="https://dom.spec.whatwg.org/#concept-event-dispatch">
51cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script>
61cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script>
71cb0ef41Sopenharmony_ci<div id=log></div>
81cb0ef41Sopenharmony_ci<table id="table" border="1" style="display: none">
91cb0ef41Sopenharmony_ci    <tbody id="table-body">
101cb0ef41Sopenharmony_ci    <tr id="table-row">
111cb0ef41Sopenharmony_ci        <td id="table-cell">Shady Grove</td>
121cb0ef41Sopenharmony_ci        <td>Aeolian</td>
131cb0ef41Sopenharmony_ci    </tr>
141cb0ef41Sopenharmony_ci    <tr id="parent">
151cb0ef41Sopenharmony_ci        <td id="target">Over the river, Charlie</td>
161cb0ef41Sopenharmony_ci        <td>Dorian</td>
171cb0ef41Sopenharmony_ci    </tr>
181cb0ef41Sopenharmony_ci    </tbody>
191cb0ef41Sopenharmony_ci</table>
201cb0ef41Sopenharmony_ci<script>
211cb0ef41Sopenharmony_citest(function() {
221cb0ef41Sopenharmony_ci    var event_type = "foo";
231cb0ef41Sopenharmony_ci    var target = document.getElementById("target");
241cb0ef41Sopenharmony_ci    var parent = document.getElementById("parent");
251cb0ef41Sopenharmony_ci    var tbody = document.getElementById("table-body");
261cb0ef41Sopenharmony_ci    var table = document.getElementById("table");
271cb0ef41Sopenharmony_ci    var body = document.body;
281cb0ef41Sopenharmony_ci    var html = document.documentElement;
291cb0ef41Sopenharmony_ci    var targets = [window, document, html, body, table, tbody, parent, target];
301cb0ef41Sopenharmony_ci    var expected_targets = targets.concat([target, parent, tbody, table, body, html, document, window]);
311cb0ef41Sopenharmony_ci    var phases = [
321cb0ef41Sopenharmony_ci        Event.CAPTURING_PHASE,
331cb0ef41Sopenharmony_ci        Event.CAPTURING_PHASE,
341cb0ef41Sopenharmony_ci        Event.CAPTURING_PHASE,
351cb0ef41Sopenharmony_ci        Event.CAPTURING_PHASE,
361cb0ef41Sopenharmony_ci        Event.CAPTURING_PHASE,
371cb0ef41Sopenharmony_ci        Event.CAPTURING_PHASE,
381cb0ef41Sopenharmony_ci        Event.CAPTURING_PHASE,
391cb0ef41Sopenharmony_ci        Event.AT_TARGET,
401cb0ef41Sopenharmony_ci        Event.AT_TARGET,
411cb0ef41Sopenharmony_ci        Event.BUBBLING_PHASE,
421cb0ef41Sopenharmony_ci        Event.BUBBLING_PHASE,
431cb0ef41Sopenharmony_ci        Event.BUBBLING_PHASE,
441cb0ef41Sopenharmony_ci        Event.BUBBLING_PHASE,
451cb0ef41Sopenharmony_ci        Event.BUBBLING_PHASE,
461cb0ef41Sopenharmony_ci        Event.BUBBLING_PHASE,
471cb0ef41Sopenharmony_ci        Event.BUBBLING_PHASE,
481cb0ef41Sopenharmony_ci    ];
491cb0ef41Sopenharmony_ci
501cb0ef41Sopenharmony_ci    var actual_targets = [], actual_phases = [];
511cb0ef41Sopenharmony_ci    var test_event = this.step_func(function(evt) {
521cb0ef41Sopenharmony_ci        if (parent === target.parentNode) {
531cb0ef41Sopenharmony_ci            var table_row = document.getElementById("table-row");
541cb0ef41Sopenharmony_ci            table_row.appendChild(parent.removeChild(target));
551cb0ef41Sopenharmony_ci        }
561cb0ef41Sopenharmony_ci
571cb0ef41Sopenharmony_ci        actual_targets.push(evt.currentTarget);
581cb0ef41Sopenharmony_ci        actual_phases.push(evt.eventPhase);
591cb0ef41Sopenharmony_ci    });
601cb0ef41Sopenharmony_ci
611cb0ef41Sopenharmony_ci    for (var i = 0; i < targets.length; i++) {
621cb0ef41Sopenharmony_ci        targets[i].addEventListener(event_type, test_event, true);
631cb0ef41Sopenharmony_ci        targets[i].addEventListener(event_type, test_event, false);
641cb0ef41Sopenharmony_ci    }
651cb0ef41Sopenharmony_ci
661cb0ef41Sopenharmony_ci    var evt = document.createEvent("Event");
671cb0ef41Sopenharmony_ci    evt.initEvent(event_type, true, true);
681cb0ef41Sopenharmony_ci    target.dispatchEvent(evt);
691cb0ef41Sopenharmony_ci
701cb0ef41Sopenharmony_ci    assert_array_equals(actual_targets, expected_targets, "targets");
711cb0ef41Sopenharmony_ci    assert_array_equals(actual_phases, phases, "phases");
721cb0ef41Sopenharmony_ci}, "Event propagation path when an element in it is moved within the DOM");
731cb0ef41Sopenharmony_ci</script>
74