Skip to content

Commit 70558bf

Browse files
committed
Bug 1950487 [wpt PR 50945] - DOM: Add slotchange test for moveBefore(), a=testonly
Automatic update from web-platform-tests DOM: Add slotchange test for moveBefore() This CL adds a test to ensure that the 'slotchange' event is fired when slots themselves are moved in and out of a custom element, and their assigned nodes change. This addresses whatwg/dom#1307 (comment). R=nrosenthal Bug: 40150299 Change-Id: I93ee04294e5ab3e6d9f75c48705cdc77ce0a1df3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6298941 Commit-Queue: Dominic Farolino <domchromium.org> Reviewed-by: Noam Rosenthal <nrosenthalchromium.org> Cr-Commit-Position: refs/heads/main{#1424746} -- wpt-commits: cd2cfbab2d2157b1c409be1631ff7e42c3ae7f6f wpt-pr: 50945 UltraBlame original commit: 4a6a1072a3e50a2172f5d712305e8a77f170e452
1 parent 7f15ec3 commit 70558bf

File tree

1 file changed

+316
-0
lines changed

1 file changed

+316
-0
lines changed

testing/web-platform/tests/dom/nodes/moveBefore/tentative/slotchange-events.html

Lines changed: 316 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,322 @@
946946
"
947947
)
948948
;
949+
promise_test
950+
(
951+
async
952+
t
953+
=
954+
>
955+
{
956+
const
957+
customElement
958+
=
959+
document
960+
.
961+
body
962+
.
963+
appendChild
964+
(
965+
document
966+
.
967+
createElement
968+
(
969+
'
970+
custom
971+
-
972+
element
973+
'
974+
)
975+
)
976+
;
977+
const
978+
slot
979+
=
980+
customElement
981+
.
982+
shadowRoot
983+
.
984+
children
985+
[
986+
0
987+
]
988+
;
989+
t
990+
.
991+
add_cleanup
992+
(
993+
(
994+
)
995+
=
996+
>
997+
customElement
998+
.
999+
remove
1000+
(
1001+
)
1002+
)
1003+
;
1004+
const
1005+
p
1006+
=
1007+
document
1008+
.
1009+
createElement
1010+
(
1011+
'
1012+
p
1013+
'
1014+
)
1015+
;
1016+
p
1017+
.
1018+
slot
1019+
=
1020+
'
1021+
content
1022+
'
1023+
;
1024+
p
1025+
.
1026+
textContent
1027+
=
1028+
'
1029+
The
1030+
content
1031+
'
1032+
;
1033+
customElement
1034+
.
1035+
appendChild
1036+
(
1037+
p
1038+
)
1039+
;
1040+
/
1041+
/
1042+
See
1043+
the
1044+
above
1045+
tests
1046+
that
1047+
do
1048+
the
1049+
same
1050+
thing
1051+
for
1052+
implementations
1053+
that
1054+
do
1055+
not
1056+
fire
1057+
slotchange
1058+
/
1059+
/
1060+
at
1061+
this
1062+
phase
1063+
.
1064+
await
1065+
new
1066+
Promise
1067+
(
1068+
resolve
1069+
=
1070+
>
1071+
t
1072+
.
1073+
step_timeout
1074+
(
1075+
(
1076+
)
1077+
=
1078+
>
1079+
resolve
1080+
(
1081+
)
1082+
)
1083+
)
1084+
;
1085+
assert_array_equals
1086+
(
1087+
slot
1088+
.
1089+
assignedNodes
1090+
(
1091+
)
1092+
[
1093+
p
1094+
]
1095+
)
1096+
;
1097+
document
1098+
.
1099+
body
1100+
.
1101+
moveBefore
1102+
(
1103+
slot
1104+
null
1105+
)
1106+
;
1107+
await
1108+
new
1109+
Promise
1110+
(
1111+
(
1112+
resolve
1113+
reject
1114+
)
1115+
=
1116+
>
1117+
{
1118+
slot
1119+
.
1120+
addEventListener
1121+
(
1122+
'
1123+
slotchange
1124+
'
1125+
e
1126+
=
1127+
>
1128+
resolve
1129+
(
1130+
)
1131+
{
1132+
once
1133+
:
1134+
true
1135+
}
1136+
)
1137+
;
1138+
t
1139+
.
1140+
step_timeout
1141+
(
1142+
(
1143+
)
1144+
=
1145+
>
1146+
reject
1147+
(
1148+
'
1149+
Timeout
1150+
;
1151+
slotchange
1152+
was
1153+
not
1154+
fired2
1155+
'
1156+
)
1157+
1500
1158+
)
1159+
;
1160+
}
1161+
)
1162+
;
1163+
assert_array_equals
1164+
(
1165+
slot
1166+
.
1167+
assignedNodes
1168+
(
1169+
)
1170+
[
1171+
]
1172+
)
1173+
;
1174+
customElement
1175+
.
1176+
shadowRoot
1177+
.
1178+
moveBefore
1179+
(
1180+
slot
1181+
null
1182+
)
1183+
;
1184+
await
1185+
new
1186+
Promise
1187+
(
1188+
(
1189+
resolve
1190+
reject
1191+
)
1192+
=
1193+
>
1194+
{
1195+
slot
1196+
.
1197+
addEventListener
1198+
(
1199+
'
1200+
slotchange
1201+
'
1202+
e
1203+
=
1204+
>
1205+
resolve
1206+
(
1207+
)
1208+
{
1209+
once
1210+
:
1211+
true
1212+
}
1213+
)
1214+
;
1215+
t
1216+
.
1217+
step_timeout
1218+
(
1219+
(
1220+
)
1221+
=
1222+
>
1223+
reject
1224+
(
1225+
'
1226+
Timeout
1227+
;
1228+
slotchange
1229+
was
1230+
not
1231+
fired3
1232+
'
1233+
)
1234+
1500
1235+
)
1236+
;
1237+
}
1238+
)
1239+
;
1240+
assert_array_equals
1241+
(
1242+
slot
1243+
.
1244+
assignedNodes
1245+
(
1246+
)
1247+
[
1248+
p
1249+
]
1250+
)
1251+
;
1252+
}
1253+
"
1254+
Moving
1255+
a
1256+
slot
1257+
runs
1258+
the
1259+
assign
1260+
slottables
1261+
algorithm
1262+
"
1263+
)
1264+
;
9491265
<
9501266
/
9511267
script

0 commit comments

Comments
 (0)