blob: b75732257a89dd1174d9904239e7899ce7b85fab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<!DOCTYPE html>
<meta charset="utf-8">
<title>Event's stopImmediatePropagation</title>
<link rel="help" href="https://dom.spec.whatwg.org/#dom-event-stopimmediatepropagation">
<link rel="author" href="mailto:d@domenic.me" title="Domenic Denicola">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="target"></div>
<script>
"use strict";
setup({ single_test: true });
const target = document.querySelector("#target");
let timesCalled = 0;
target.addEventListener("test", e => {
++timesCalled;
e.stopImmediatePropagation();
assert_equals(e.cancelBubble, true, "The stop propagation flag must have been set");
});
target.addEventListener("test", () => {
++timesCalled;
});
const e = new Event("test");
target.dispatchEvent(e);
assert_equals(timesCalled, 1, "The second listener must not have been called");
done();
</script>
|