11cb0ef41Sopenharmony_ci<!DOCTYPE html>
21cb0ef41Sopenharmony_ci<meta charset="utf-8">
31cb0ef41Sopenharmony_ci<title>Event's stopImmediatePropagation</title>
41cb0ef41Sopenharmony_ci<link rel="help" href="https://dom.spec.whatwg.org/#dom-event-stopimmediatepropagation">
51cb0ef41Sopenharmony_ci<link rel="author" href="mailto:d@domenic.me" title="Domenic Denicola">
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script>
81cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script>
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci<div id="target"></div>
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ci<script>
131cb0ef41Sopenharmony_ci"use strict";
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_cisetup({ single_test: true });
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ciconst target = document.querySelector("#target");
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_cilet timesCalled = 0;
201cb0ef41Sopenharmony_citarget.addEventListener("test", e => {
211cb0ef41Sopenharmony_ci  ++timesCalled;
221cb0ef41Sopenharmony_ci  e.stopImmediatePropagation();
231cb0ef41Sopenharmony_ci  assert_equals(e.cancelBubble, true, "The stop propagation flag must have been set");
241cb0ef41Sopenharmony_ci});
251cb0ef41Sopenharmony_citarget.addEventListener("test", () => {
261cb0ef41Sopenharmony_ci  ++timesCalled;
271cb0ef41Sopenharmony_ci});
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ciconst e = new Event("test");
301cb0ef41Sopenharmony_citarget.dispatchEvent(e);
311cb0ef41Sopenharmony_ciassert_equals(timesCalled, 1, "The second listener must not have been called");
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_cidone();
341cb0ef41Sopenharmony_ci</script>
35