| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src="../resources/testharness.js"></script> | 2 <script src="../resources/testharness.js"></script> |
| 3 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
| 4 <script src="resources/shadow-dom.js"></script> | 4 <script src="resources/shadow-dom.js"></script> |
| 5 | 5 |
| 6 <div id="test1"> | 6 <div id="test1"> |
| 7 <div id="host1"> | 7 <div id="host1"> |
| 8 <template data-mode="open"> | 8 <template id="shadowroot" data-mode="open"> |
| 9 <slot id="s1" name="slot1"></slot> | 9 <slot id="s1" name="slot1"></slot> |
| 10 </template> | 10 </template> |
| 11 <div id="c1" slot="slot1"></div> | 11 <div id="c1" slot="slot1"></div> |
| 12 </div> | 12 </div> |
| 13 </div> | 13 </div> |
| 14 | 14 |
| 15 <script> | 15 <script> |
| 16 function doneIfSlotChange(slots, test) { | 16 function doneIfSlotChange(slots, test) { |
| 17 let fired = new Set(); | 17 let fired = new Set(); |
| 18 for (let slot of slots) { | 18 for (let slot of slots) { |
| 19 slot.addEventListener('slotchange', test.step_func((e) => { | 19 slot.addEventListener('slotchange', test.step_func((e) => { |
| 20 assert_false(fired.has(slot.id)); | 20 assert_false(fired.has(slot.id)); |
| 21 fired.add(slot.id); | 21 fired.add(slot.id); |
| 22 if (fired.size == slots.length) { | 22 if (fired.size == slots.length) { |
| 23 test.done(); | 23 test.done(); |
| 24 } | 24 } |
| 25 })) | 25 })) |
| 26 } | 26 } |
| 27 } | 27 } |
| 28 | 28 |
| 29 async_test((test) => { | 29 async_test((test) => { |
| 30 let n = createTestTree(test1); | 30 let n = createTestTree(test1); |
| 31 removeWhiteSpaceOnlyTextNodes(n.test1); | 31 removeWhiteSpaceOnlyTextNodes(n.test1); |
| 32 | 32 |
| 33 n.shadowroot.addEventListener('slotchange', test.step_func_done((e) => { |
| 34 assert_true(event.bubbles, 'A slotchange should be a bubbling event'); |
| 35 assert_false(event.composed, 'A slotchange should be a non-composed event') |
| 36 assert_equals(event.target, n.s1); |
| 37 })) |
| 38 |
| 39 let d1 = document.createElement('div'); |
| 40 d1.setAttribute('slot', 'slot1'); |
| 41 n.host1.appendChild(d1); |
| 42 }, 'A slotchange event shoud be a bubble, non-composed event.'); |
| 43 |
| 44 async_test((test) => { |
| 45 let n = createTestTree(test1); |
| 46 removeWhiteSpaceOnlyTextNodes(n.test1); |
| 47 |
| 33 doneIfSlotChange([n.s1], test); | 48 doneIfSlotChange([n.s1], test); |
| 34 | 49 |
| 35 let d1 = document.createElement('div'); | 50 let d1 = document.createElement('div'); |
| 36 d1.setAttribute('slot', 'slot1'); | 51 d1.setAttribute('slot', 'slot1'); |
| 37 n.host1.appendChild(d1); | 52 n.host1.appendChild(d1); |
| 38 }, 'slotchange event: Append a child to a host.'); | 53 }, 'slotchange event: Append a child to a host.'); |
| 39 | 54 |
| 40 async_test((test) => { | 55 async_test((test) => { |
| 41 let n = createTestTree(test1); | 56 let n = createTestTree(test1); |
| 42 removeWhiteSpaceOnlyTextNodes(n.test1); | 57 removeWhiteSpaceOnlyTextNodes(n.test1); |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 <script> | 274 <script> |
| 260 async_test((test) => { | 275 async_test((test) => { |
| 261 let n = createTestTree(test6); | 276 let n = createTestTree(test6); |
| 262 removeWhiteSpaceOnlyTextNodes(n.test6); | 277 removeWhiteSpaceOnlyTextNodes(n.test6); |
| 263 | 278 |
| 264 doneIfSlotChange([n.s2], test); | 279 doneIfSlotChange([n.s2], test); |
| 265 | 280 |
| 266 n.s1.remove(); | 281 n.s1.remove(); |
| 267 }, "slotchange event: Even if distributed nodes do not change, slotchange should
be fired if assigned nodes are changed."); | 282 }, "slotchange event: Even if distributed nodes do not change, slotchange should
be fired if assigned nodes are changed."); |
| 268 </script> | 283 </script> |
| OLD | NEW |