11cb0ef41Sopenharmony_ci<!DOCTYPE html>
21cb0ef41Sopenharmony_ci<meta charset=utf-8>
31cb0ef41Sopenharmony_ci<title> Event.bubbles attribute is set to false </title>
41cb0ef41Sopenharmony_ci<link rel="help" href="https://dom.spec.whatwg.org/#dom-event-initevent">
51cb0ef41Sopenharmony_ci<link rel="help" href="https://dom.spec.whatwg.org/#concept-event-dispatch">
61cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script>
71cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script>
81cb0ef41Sopenharmony_ci<div id=log></div>
91cb0ef41Sopenharmony_ci<table id="table" border="1" style="display: none">
101cb0ef41Sopenharmony_ci    <tbody id="table-body">
111cb0ef41Sopenharmony_ci    <tr id="table-row">
121cb0ef41Sopenharmony_ci        <td id="table-cell">Shady Grove</td>
131cb0ef41Sopenharmony_ci        <td>Aeolian</td>
141cb0ef41Sopenharmony_ci    </tr>
151cb0ef41Sopenharmony_ci    <tr id="parent">
161cb0ef41Sopenharmony_ci        <td id="target">Over the river, Charlie</td>
171cb0ef41Sopenharmony_ci        <td>Dorian</td>
181cb0ef41Sopenharmony_ci    </tr>
191cb0ef41Sopenharmony_ci    </tbody>
201cb0ef41Sopenharmony_ci</table>
211cb0ef41Sopenharmony_ci<script>
221cb0ef41Sopenharmony_cifunction targetsForDocumentChain(document) {
231cb0ef41Sopenharmony_ci    return [
241cb0ef41Sopenharmony_ci        document,
251cb0ef41Sopenharmony_ci        document.documentElement,
261cb0ef41Sopenharmony_ci        document.getElementsByTagName("body")[0],
271cb0ef41Sopenharmony_ci        document.getElementById("table"),
281cb0ef41Sopenharmony_ci        document.getElementById("table-body"),
291cb0ef41Sopenharmony_ci        document.getElementById("parent")
301cb0ef41Sopenharmony_ci    ];
311cb0ef41Sopenharmony_ci}
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_cifunction testChain(document, targetParents, phases, event_type) {
341cb0ef41Sopenharmony_ci    var target = document.getElementById("target");
351cb0ef41Sopenharmony_ci    var targets = targetParents.concat(target);
361cb0ef41Sopenharmony_ci    var expected_targets = targets.concat(target);
371cb0ef41Sopenharmony_ci
381cb0ef41Sopenharmony_ci    var actual_targets = [], actual_phases = [];
391cb0ef41Sopenharmony_ci    var test_event = function(evt) {
401cb0ef41Sopenharmony_ci        actual_targets.push(evt.currentTarget);
411cb0ef41Sopenharmony_ci        actual_phases.push(evt.eventPhase);
421cb0ef41Sopenharmony_ci    }
431cb0ef41Sopenharmony_ci
441cb0ef41Sopenharmony_ci    for (var i = 0; i < targets.length; i++) {
451cb0ef41Sopenharmony_ci        targets[i].addEventListener(event_type, test_event, true);
461cb0ef41Sopenharmony_ci        targets[i].addEventListener(event_type, test_event, false);
471cb0ef41Sopenharmony_ci    }
481cb0ef41Sopenharmony_ci
491cb0ef41Sopenharmony_ci    var evt = document.createEvent("Event");
501cb0ef41Sopenharmony_ci    evt.initEvent(event_type, false, true);
511cb0ef41Sopenharmony_ci
521cb0ef41Sopenharmony_ci    target.dispatchEvent(evt);
531cb0ef41Sopenharmony_ci
541cb0ef41Sopenharmony_ci    assert_array_equals(actual_targets, expected_targets, "targets");
551cb0ef41Sopenharmony_ci    assert_array_equals(actual_phases, phases, "phases");
561cb0ef41Sopenharmony_ci}
571cb0ef41Sopenharmony_ci
581cb0ef41Sopenharmony_civar phasesForDocumentChain = [
591cb0ef41Sopenharmony_ci    Event.CAPTURING_PHASE,
601cb0ef41Sopenharmony_ci    Event.CAPTURING_PHASE,
611cb0ef41Sopenharmony_ci    Event.CAPTURING_PHASE,
621cb0ef41Sopenharmony_ci    Event.CAPTURING_PHASE,
631cb0ef41Sopenharmony_ci    Event.CAPTURING_PHASE,
641cb0ef41Sopenharmony_ci    Event.CAPTURING_PHASE,
651cb0ef41Sopenharmony_ci    Event.AT_TARGET,
661cb0ef41Sopenharmony_ci    Event.AT_TARGET,
671cb0ef41Sopenharmony_ci];
681cb0ef41Sopenharmony_ci
691cb0ef41Sopenharmony_citest(function () {
701cb0ef41Sopenharmony_ci    var chainWithWindow = [window].concat(targetsForDocumentChain(document));
711cb0ef41Sopenharmony_ci    testChain(
721cb0ef41Sopenharmony_ci        document, chainWithWindow, [Event.CAPTURING_PHASE].concat(phasesForDocumentChain), "click");
731cb0ef41Sopenharmony_ci}, "In window.document with click event");
741cb0ef41Sopenharmony_ci
751cb0ef41Sopenharmony_citest(function () {
761cb0ef41Sopenharmony_ci    testChain(document, targetsForDocumentChain(document), phasesForDocumentChain, "load");
771cb0ef41Sopenharmony_ci}, "In window.document with load event")
781cb0ef41Sopenharmony_ci
791cb0ef41Sopenharmony_citest(function () {
801cb0ef41Sopenharmony_ci    var documentClone = document.cloneNode(true);
811cb0ef41Sopenharmony_ci    testChain(
821cb0ef41Sopenharmony_ci        documentClone, targetsForDocumentChain(documentClone), phasesForDocumentChain, "click");
831cb0ef41Sopenharmony_ci}, "In window.document.cloneNode(true)");
841cb0ef41Sopenharmony_ci
851cb0ef41Sopenharmony_citest(function () {
861cb0ef41Sopenharmony_ci    var newDocument = new Document();
871cb0ef41Sopenharmony_ci    newDocument.appendChild(document.documentElement.cloneNode(true));
881cb0ef41Sopenharmony_ci    testChain(
891cb0ef41Sopenharmony_ci        newDocument, targetsForDocumentChain(newDocument), phasesForDocumentChain, "click");
901cb0ef41Sopenharmony_ci}, "In new Document()");
911cb0ef41Sopenharmony_ci
921cb0ef41Sopenharmony_citest(function () {
931cb0ef41Sopenharmony_ci    var HTMLDocument = document.implementation.createHTMLDocument();
941cb0ef41Sopenharmony_ci    HTMLDocument.body.appendChild(document.getElementById("table").cloneNode(true));
951cb0ef41Sopenharmony_ci    testChain(
961cb0ef41Sopenharmony_ci        HTMLDocument, targetsForDocumentChain(HTMLDocument), phasesForDocumentChain, "click");
971cb0ef41Sopenharmony_ci}, "In DOMImplementation.createHTMLDocument()");
981cb0ef41Sopenharmony_ci</script>
99