Skip to content

Commit 6a6849b

Browse files
authored
Update CommandEvent tests to expect an uncomposed event
For whatwg/html#11255.
1 parent e3cea74 commit 6a6849b

File tree

2 files changed

+6
-71
lines changed

2 files changed

+6
-71
lines changed

html/semantics/the-button-element/command-and-commandfor/button-event-dispatch.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
assert_true(event instanceof CommandEvent, "event is CommandEvent");
3131
assert_equals(event.type, "command", "type");
3232
assert_equals(event.bubbles, false, "bubbles");
33-
assert_equals(event.composed, true, "composed");
33+
assert_equals(event.composed, false, "composed");
3434
assert_equals(event.isTrusted, true, "isTrusted");
3535
assert_equals(event.command, "--custom-command", "command");
3636
assert_equals(event.target, invokee, "target");
@@ -47,7 +47,7 @@
4747
assert_true(event instanceof CommandEvent, "event is CommandEvent");
4848
assert_equals(event.type, "command", "type");
4949
assert_equals(event.bubbles, false, "bubbles");
50-
assert_equals(event.composed, true, "composed");
50+
assert_equals(event.composed, false, "composed");
5151
assert_equals(event.isTrusted, true, "isTrusted");
5252
assert_equals(event.command, "--custom-command", "command");
5353
assert_equals(event.target, invokee, "target");
@@ -66,7 +66,7 @@
6666
assert_true(event instanceof CommandEvent, "event is CommandEvent");
6767
assert_equals(event.type, "command", "type");
6868
assert_equals(event.bubbles, false, "bubbles");
69-
assert_equals(event.composed, true, "composed");
69+
assert_equals(event.composed, false, "composed");
7070
assert_equals(event.isTrusted, true, "isTrusted");
7171
assert_equals(event.command, command, "command");
7272
assert_equals(event.target, invokee, "target");
@@ -82,7 +82,7 @@
8282
assert_true(event instanceof CommandEvent, "event is CommandEvent");
8383
assert_equals(event.type, "command", "type");
8484
assert_equals(event.bubbles, false, "bubbles");
85-
assert_equals(event.composed, true, "composed");
85+
assert_equals(event.composed, false, "composed");
8686
assert_equals(event.isTrusted, true, "isTrusted");
8787
assert_equals(event.command, command, "command");
8888
assert_equals(event.target, invokee, "target");
@@ -178,7 +178,7 @@
178178
assert_true(event instanceof CommandEvent, "event is CommandEvent");
179179
assert_equals(event.type, "command", "type");
180180
assert_equals(event.bubbles, false, "bubbles");
181-
assert_equals(event.composed, true, "composed");
181+
assert_equals(event.composed, false, "composed");
182182
assert_equals(event.isTrusted, true, "isTrusted");
183183
assert_equals(event.command, "--custom-command", "command");
184184
assert_equals(event.target, invokee, "target");

html/semantics/the-button-element/command-and-commandfor/event-dispatch-shadow.html

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -6,73 +6,7 @@
66
<script src="/resources/testharnessreport.js"></script>
77
<script src="resources/invoker-utils.js"></script>
88

9-
<div id="div"></div>
10-
<button id="button"></button>
11-
129
<script>
13-
test(function () {
14-
const host = document.createElement("div");
15-
const child = host.appendChild(document.createElement("p"));
16-
const shadow = host.attachShadow({ mode: "closed" });
17-
const slot = shadow.appendChild(document.createElement("slot"));
18-
let childEvent = null;
19-
let childEventTarget = null;
20-
let childEventSource = null;
21-
let hostEvent = null;
22-
let hostEventTarget = null;
23-
let hostEventSource = null;
24-
slot.addEventListener(
25-
"command",
26-
(e) => {
27-
childEvent = e;
28-
childEventTarget = e.target;
29-
childEventSource = e.source;
30-
},
31-
{ once: true },
32-
);
33-
host.addEventListener(
34-
"command",
35-
(e) => {
36-
hostEvent = e;
37-
hostEventTarget = e.target;
38-
hostEventSource = e.source;
39-
},
40-
{ once: true },
41-
);
42-
const event = new CommandEvent("command", {
43-
bubbles: true,
44-
source: slot,
45-
composed: true,
46-
});
47-
slot.dispatchEvent(event);
48-
assert_true(childEvent instanceof CommandEvent, "slot saw invoke event");
49-
assert_equals(
50-
childEventTarget,
51-
slot,
52-
"target is child inside shadow boundary",
53-
);
54-
assert_equals(
55-
childEventSource,
56-
slot,
57-
"source is child inside shadow boundary",
58-
);
59-
assert_equals(
60-
hostEvent,
61-
childEvent,
62-
"event dispatch propagates across shadow boundary",
63-
);
64-
assert_equals(
65-
hostEventTarget,
66-
host,
67-
"target is retargeted to shadowroot host",
68-
);
69-
assert_equals(
70-
hostEventSource,
71-
host,
72-
"source is retargeted to shadowroot host",
73-
);
74-
}, "CommandEvent propagates across shadow boundaries retargeting source");
75-
7610
test(function (t) {
7711
const host = document.createElement("div");
7812
document.body.append(host);
@@ -96,6 +30,7 @@
9630
);
9731
button.click();
9832
assert_true(event instanceof CommandEvent);
33+
assert_equals(event.composed, false, "composed is false");
9934
assert_equals(eventTarget, invokee, "target is invokee");
10035
assert_equals(eventSource, host, "source is host");
10136
}, "cross shadow CommandEvent retargets source to host element");

0 commit comments

Comments
 (0)