11cb0ef41Sopenharmony_ci<!DOCTYPE html> 21cb0ef41Sopenharmony_ci<html> 31cb0ef41Sopenharmony_ci<head> 41cb0ef41Sopenharmony_ci<title>Setting cancelBubble=true prior to dispatchEvent()</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<table id="table" border="1" style="display: none"> 121cb0ef41Sopenharmony_ci <tbody id="table-body"> 131cb0ef41Sopenharmony_ci <tr id="table-row"> 141cb0ef41Sopenharmony_ci <td id="table-cell">Shady Grove</td> 151cb0ef41Sopenharmony_ci <td>Aeolian</td> 161cb0ef41Sopenharmony_ci </tr> 171cb0ef41Sopenharmony_ci <tr id="parent"> 181cb0ef41Sopenharmony_ci <td id="target">Over the river, Charlie</td> 191cb0ef41Sopenharmony_ci <td>Dorian</td> 201cb0ef41Sopenharmony_ci </tr> 211cb0ef41Sopenharmony_ci </tbody> 221cb0ef41Sopenharmony_ci</table> 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci<script> 251cb0ef41Sopenharmony_citest(function() { 261cb0ef41Sopenharmony_ci var event = "foo"; 271cb0ef41Sopenharmony_ci var target = document.getElementById("target"); 281cb0ef41Sopenharmony_ci var parent = document.getElementById("parent"); 291cb0ef41Sopenharmony_ci var tbody = document.getElementById("table-body"); 301cb0ef41Sopenharmony_ci var table = document.getElementById("table"); 311cb0ef41Sopenharmony_ci var body = document.body; 321cb0ef41Sopenharmony_ci var html = document.documentElement; 331cb0ef41Sopenharmony_ci var current_targets = [window, document, html, body, table, tbody, parent, target]; 341cb0ef41Sopenharmony_ci var expected_targets = []; 351cb0ef41Sopenharmony_ci var actual_targets = []; 361cb0ef41Sopenharmony_ci var expected_phases = []; 371cb0ef41Sopenharmony_ci var actual_phases = []; 381cb0ef41Sopenharmony_ci 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 < current_targets.length; ++i) { 451cb0ef41Sopenharmony_ci current_targets[i].addEventListener(event, test_event, true); 461cb0ef41Sopenharmony_ci current_targets[i].addEventListener(event, test_event, false); 471cb0ef41Sopenharmony_ci } 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ci var evt = document.createEvent("Event"); 501cb0ef41Sopenharmony_ci evt.initEvent(event, true, true); 511cb0ef41Sopenharmony_ci evt.cancelBubble = true; 521cb0ef41Sopenharmony_ci target.dispatchEvent(evt); 531cb0ef41Sopenharmony_ci 541cb0ef41Sopenharmony_ci assert_array_equals(actual_targets, expected_targets, "actual_targets"); 551cb0ef41Sopenharmony_ci assert_array_equals(actual_phases, expected_phases, "actual_phases"); 561cb0ef41Sopenharmony_ci}); 571cb0ef41Sopenharmony_ci</script> 581cb0ef41Sopenharmony_ci</body> 591cb0ef41Sopenharmony_ci</html> 60