Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script src='../../../resources/testharness.js'></script> | |
| 3 <script src='../../../resources/testharnessreport.js'></script> | |
| 4 <script src='resources/shadow-dom.js'></script> | |
| 5 <div id='host'> | |
| 6 <template data-mode='open'> | |
| 7 <div id='shadow-child1'></div> | |
| 8 <slot></slot> | |
| 9 <slot name='slot1'></slot> | |
| 10 <div id='shadow-child2'></div> | |
| 11 </template> | |
| 12 <div id='child1' slot='slot1'></div> | |
| 13 Hello | |
| 14 <div id='child2'></div> | |
| 15 World | |
| 16 <div id='child3' slot='nonexistent'></div> | |
| 17 </div> | |
| 18 <script> | |
| 19 'use strict'; | |
| 20 convertTemplatesToShadowRootsWithin(host); | |
| 21 removeWhiteSpaceOnlyTextNodes(host); | |
| 22 document.body.offsetLeft; | |
| 23 | |
| 24 const slot1 = host.shadowRoot.querySelector('slot[name=slot1]'); | |
| 25 const defaultSlot = host.shadowRoot.querySelector('slot'); | |
| 26 const shadowChild1 = host.shadowRoot.querySelector('#shadow-child1'); | |
| 27 const shadowChild2 = host.shadowRoot.querySelector('#shadow-child2'); | |
| 28 | |
| 29 const textHello = host.childNodes[1]; | |
| 30 const textWorld = host.childNodes[3]; | |
| 31 | |
| 32 test(() => { | |
| 33 assert_equals(textHello.nodeValue.trim(), 'Hello'); | |
|
kochi
2015/12/10 05:57:23
I prefer not to use trim() here, and write the HTM
hayato
2015/12/10 08:11:21
I don't think that's worth while. Using trim() is
| |
| 34 assert_equals(textWorld.nodeValue.trim(), 'World'); | |
| 35 assert_equals(textHello.assignedSlot, defaultSlot); | |
| 36 assert_equals(textWorld.assignedSlot, defaultSlot); | |
| 37 assert_equals(child1.assignedSlot, slot1); | |
| 38 assert_equals(child2.assignedSlot, defaultSlot); | |
| 39 assert_equals(child3.assignedSlot, null); | |
| 40 }, "assignedSlot"); | |
| 41 | |
| 42 test(() => { | |
| 43 assert_array_equals(defaultSlot.getDistributedNodes(), [textHello, child2, tex tWorld]); | |
| 44 assert_array_equals(slot1.getDistributedNodes(), [child1]); | |
| 45 }, "getDistributedNodes"); | |
| 46 | |
| 47 add_completion_callback(() => { | |
| 48 if (window.testRunner) | |
| 49 host.style.display = "none"; | |
| 50 }); | |
| 51 </script> | |
| OLD | NEW |