Commit 220edbbe authored by Kyoko Muto's avatar Kyoko Muto Committed by Commit Bot

Add tests for check in manual-slotting mode in shadow DOM

The tests demonstrate that nodes which are not connected to host
should not be assigned to slot,
and slotting API should not have any effect in auto mode.

Change-Id: I9403f386f457cd198813d0f49e50cacf1ac23b4b
Reviewed-on: https://chromium-review.googlesource.com/1175505
Commit-Queue: Kyoko Muto <kymuto@google.com>
Reviewed-by: default avatarHayato Ito <hayato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583216}
parent 11cd89f6
...@@ -18,6 +18,10 @@ See https://crbug.com/869308 ...@@ -18,6 +18,10 @@ See https://crbug.com/869308
</div> </div>
<div id="host3"> <div id="host3">
</div> </div>
<div id="child4"></div>
<div id="host4">
<div id="child5"></div>
</div>
<script> <script>
...@@ -28,11 +32,18 @@ const host3 = document.querySelector('#host3'); ...@@ -28,11 +32,18 @@ const host3 = document.querySelector('#host3');
const child1 = document.querySelector('#child1'); const child1 = document.querySelector('#child1');
const child2 = document.querySelector('#child2'); const child2 = document.querySelector('#child2');
const child3 = document.querySelector('#child3'); const child3 = document.querySelector('#child3');
const child4 = document.querySelector('#child4');
const child5 = document.querySelector('#child5');
const shadow_root = host.attachShadow({ mode: 'open', slotting: 'manual' }); const shadow_root = host.attachShadow({ mode: 'open', slotting: 'manual' });
const shadow_root1 = host4.attachShadow({ mode: 'open' });
const slot1 = document.createElement('slot'); const slot1 = document.createElement('slot');
const slot2 = document.createElement('slot'); const slot2 = document.createElement('slot');
const slot3 = document.createElement('slot');
const slot4 = document.createElement('slot');
shadow_root.appendChild(slot1); shadow_root.appendChild(slot1);
shadow_root.appendChild(slot2); shadow_root.appendChild(slot2);
shadow_root.appendChild(slot3);
shadow_root1.appendChild(slot4);
test(() => { test(() => {
assert_not_equals(host1.attachShadow({ mode: 'open', slotting: 'manual' }), assert_not_equals(host1.attachShadow({ mode: 'open', slotting: 'manual' }),
...@@ -60,4 +71,20 @@ test(() => { ...@@ -60,4 +71,20 @@ test(() => {
slot1.assign([child2,child3]); slot1.assign([child2,child3]);
assert_array_equals(slot1.assignedNodes(), [child2,child3]); assert_array_equals(slot1.assignedNodes(), [child2,child3]);
}, 'assignedNodes can be used in manual slotting'); }, 'assignedNodes can be used in manual slotting');
test(() => {
slot3.assign([child4]);
assert_array_equals(slot3.assignedNodes(), []);
}, 'Nodes that is not connected to host should not be assigned');
test(() => {
assert_array_equals(slot4.assignedNodes(), [child5]);
assert_equals(child5.assignedSlot, slot4);
slot4.assign([]);
assert_array_equals(slot4.assignedNodes(), [child5]);
assert_equals(child5.assignedSlot, slot4);
}, 'slotting API should not have any effect in auto mode');
</script> </script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment