11cb0ef41Sopenharmony_ci<!DOCTYPE html> 21cb0ef41Sopenharmony_ci<meta charset="utf-8"> 31cb0ef41Sopenharmony_ci<title>Listeners are invoked in correct order (AT_TARGET phase)</title> 41cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script> 51cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script> 61cb0ef41Sopenharmony_ci<div id="log"></div> 71cb0ef41Sopenharmony_ci<script> 81cb0ef41Sopenharmony_ci"use strict"; 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_citest(() => { 111cb0ef41Sopenharmony_ci const el = document.createElement("div"); 121cb0ef41Sopenharmony_ci const expectedOrder = ["capturing", "bubbling"]; 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ci let actualOrder = []; 151cb0ef41Sopenharmony_ci el.addEventListener("click", evt => { 161cb0ef41Sopenharmony_ci assert_equals(evt.eventPhase, Event.AT_TARGET); 171cb0ef41Sopenharmony_ci actualOrder.push("bubbling"); 181cb0ef41Sopenharmony_ci }, false); 191cb0ef41Sopenharmony_ci el.addEventListener("click", evt => { 201cb0ef41Sopenharmony_ci assert_equals(evt.eventPhase, Event.AT_TARGET); 211cb0ef41Sopenharmony_ci actualOrder.push("capturing"); 221cb0ef41Sopenharmony_ci }, true); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci el.dispatchEvent(new Event("click", {bubbles: true})); 251cb0ef41Sopenharmony_ci assert_array_equals(actualOrder, expectedOrder, "bubbles: true"); 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci actualOrder = []; 281cb0ef41Sopenharmony_ci el.dispatchEvent(new Event("click", {bubbles: false})); 291cb0ef41Sopenharmony_ci assert_array_equals(actualOrder, expectedOrder, "bubbles: false"); 301cb0ef41Sopenharmony_ci}, "Listeners are invoked in correct order (AT_TARGET phase)"); 311cb0ef41Sopenharmony_ci</script> 32