diff --git a/shadow-dom/slotchange-event.html b/shadow-dom/slotchange-event.html
index 62675dea488aef..167d600a3bd0fa 100644
--- a/shadow-dom/slotchange-event.html
+++ b/shadow-dom/slotchange-event.html
@@ -241,11 +241,11 @@
testSlotchangeDoesNotFireWhenOtherSlotsChange('open', false);
testSlotchangeDoesNotFireWhenOtherSlotsChange('closed', false);
-function testSlotchangeDoesNotFireForMutationBeforeOrAfterSlotWasPresent(mode, connectedToDocument)
+function testSlotchangeDoesFireAtInsertedAndDoesNotFireForMutationAfterRemoved(mode, connectedToDocument)
{
- var test = async_test('slotchange event must not fire on a slot element inside '
- + treeName(mode, connectedToDocument)
- + ' when the shadow host was mutated before the slot was inserted or after the slot was removed');
+ var test = async_test('slotchange event must fire on a slot element when a shadow host has a slotable and the slot was inserted'
+ + ' and must not fire when the shadow host was mutated after the slot was removed inside '
+ + treeName(mode, connectedToDocument));
var host;
var slot;
@@ -273,32 +273,32 @@
setTimeout(function () {
test.step(function () {
- assert_equals(eventCount, 0,
- 'slotchange must not be fired on a slot element if the assigned nodes changed before the slot was inserted');
+ assert_equals(eventCount, 1,
+ 'slotchange must be fired on a slot element if there is assigned nodes when the slot was inserted');
host.removeChild(host.firstChild);
});
setTimeout(function () {
test.step(function () {
- assert_equals(eventCount, 1,
- 'slotchange must be fired exactly once after the assigned nodes change on a slot while the slot element was in the tree');
+ assert_equals(eventCount, 2,
+ 'slotchange must be fired after the assigned nodes change on a slot while the slot element was in the tree');
slot.parentNode.removeChild(slot);
host.appendChild(document.createElement('span'));
});
setTimeout(function () {
- assert_equals(eventCount, 1,
- 'slotchange must not be fired on a slot element if the assigned nodes changed after the slot was removed');
+ assert_equals(eventCount, 2,
+ 'slotchange must not be fired on a slot element if the assigned nodes changed after the slot was removed');
test.done();
}, 1);
}, 1);
}, 1);
}
-testSlotchangeDoesNotFireForMutationBeforeOrAfterSlotWasPresent('open', true);
-testSlotchangeDoesNotFireForMutationBeforeOrAfterSlotWasPresent('closed', true);
-testSlotchangeDoesNotFireForMutationBeforeOrAfterSlotWasPresent('open', false);
-testSlotchangeDoesNotFireForMutationBeforeOrAfterSlotWasPresent('closed', false);
+testSlotchangeDoesFireAtInsertedAndDoesNotFireForMutationAfterRemoved('open', true);
+testSlotchangeDoesFireAtInsertedAndDoesNotFireForMutationAfterRemoved('closed', true);
+testSlotchangeDoesFireAtInsertedAndDoesNotFireForMutationAfterRemoved('open', false);
+testSlotchangeDoesFireAtInsertedAndDoesNotFireForMutationAfterRemoved('closed', false);
function testSlotchangeFiresOnTransientlyPresentSlot(mode, connectedToDocument)
{
@@ -505,7 +505,11 @@
innerSlot.addEventListener('slotchange', function (event) {
event.stopPropagation();
test.step(function () {
- assert_equals(event.target, outerSlot, 'slotchange event\'s target must be the outer slot element');
+ if (innerSlotEventCount === 0) {
+ assert_equals(event.target, innerSlot, 'slotchange event\'s target must be the inner slot element at 1st slotchange');
+ } else if (innerSlotEventCount === 1) {
+ assert_equals(event.target, outerSlot, 'slotchange event\'s target must be the outer slot element at 2nd sltochange');
+ }
});
innerSlotEventCount++;
});
@@ -521,7 +525,7 @@
test.step(function () {
assert_equals(outerSlotEventCount, 1,
'slotchange must be fired on a slot element if the assigned nodes changed');
- assert_equals(innerSlotEventCount, 1,
+ assert_equals(innerSlotEventCount, 2,
'slotchange must be fired on a slot element and must bubble');
});
test.done();
diff --git a/shadow-dom/slots-fallback-in-document.html b/shadow-dom/slots-fallback-in-document.html
index 91acc5d5f2d713..846f3e03a057f2 100644
--- a/shadow-dom/slots-fallback-in-document.html
+++ b/shadow-dom/slots-fallback-in-document.html
@@ -22,9 +22,8 @@
test(() => {
assert_array_equals(n1.innerSlot.assignedNodes(), [n1.slot]);
- assert_array_equals(n1.innerSlot.assignedNodes({ flatten: true }),
- [n1.fallback]);
-}, 'Slot fallback content in document tree should be counted in flattened ' +
+ assert_array_equals(n1.innerSlot.assignedNodes({ flatten: true }), [n1.slot]);
+}, 'Children of a slot in a document tree should not be counted in flattened ' +
'assigned nodes.');
diff --git a/shadow-dom/slots-fallback.html b/shadow-dom/slots-fallback.html
index 8721fe9206946c..a8d60e88182f10 100644
--- a/shadow-dom/slots-fallback.html
+++ b/shadow-dom/slots-fallback.html
@@ -213,7 +213,8 @@
assert_array_equals(n.s1.assignedNodes(), []);
- assert_array_equals(n.s1.assignedNodes({ flatten: true }), [n.f1]);
+ assert_array_equals(n.s1.assignedNodes({ flatten: true }), [],
+ 'fall back contents should be empty because s1 is not in a shadow tree.');
assert_array_equals(n.s2.assignedNodes({ flatten: true }), [n.f2]);
assert_array_equals(n.s3.assignedNodes({ flatten: true }), [n.f2]);
assert_array_equals(n.s4.assignedNodes({ flatten: true }), [n.f2, n.f4]);
diff --git a/shadow-dom/slots.html b/shadow-dom/slots.html
index 67e1589ed733eb..550d7d454aa2be 100644
--- a/shadow-dom/slots.html
+++ b/shadow-dom/slots.html
@@ -83,9 +83,9 @@
assert_array_equals(n.s2.assignedNodes(), []);
assert_array_equals(n.s3.assignedNodes(), []);
- assert_array_equals(n.s1.assignedNodes({ flatten: true }), [n.c1]);
- assert_array_equals(n.s2.assignedNodes({ flatten: true }), [n.c2, n.c3_1, n.c3_2]);
- assert_array_equals(n.s3.assignedNodes({ flatten: true }), [n.c3_1, n.c3_2]);
+ assert_array_equals(n.s1.assignedNodes({ flatten: true }), []);
+ assert_array_equals(n.s2.assignedNodes({ flatten: true }), []);
+ assert_array_equals(n.s3.assignedNodes({ flatten: true }), []);
}, 'Slots: Distributed nooes for Slots not in a shadow tree.');