Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script src="../../../resources/testharness.js"></script> | |
| 3 <script src="../../../resources/testharnessreport.js"></script> | |
| 4 <div id="host-parent"> | |
| 5 <div id="host"> | |
| 6 </div> | |
| 7 <div id="slotted"></div> | |
| 8 </div> | |
| 9 <div id="host-parent2"> | |
| 10 <div id="host2"> | |
| 11 </div> | |
| 12 <div id="distributed" id="distributed"></div> | |
| 13 </div> | |
| 14 | |
| 15 <script> | |
| 16 var hostParent = document.getElementById('host-parent'); | |
| 17 var host = document.getElementById('host'); | |
| 18 var slotted = document.getElementById('slotted'); | |
| 19 var root = host.attachShadow({mode: 'open'}); | |
| 20 var child = document.createElement('div'); | |
| 21 var grandchild = document.createElement('div'); | |
| 22 var slot = document.createElement('slot'); | |
| 23 slot.setAttribute('name', 'slot'); | |
| 24 slotted.setAttribute('slot', 'slot'); | |
| 25 child.setAttribute('id', 'child'); | |
| 26 grandchild.setAttribute('id', 'grandchild'); | |
| 27 root.appendChild(child); | |
| 28 child.appendChild(grandchild); | |
| 29 grandchild.appendChild(slot); | |
| 30 | |
| 31 test(function() { | |
| 32 assert_equals(document.treeRoot, document); | |
| 33 assert_equals(hostParent.treeRoot, document); | |
| 34 assert_equals(host.treeRoot, document); | |
| 35 assert_equals(root.treeRoot, root); | |
| 36 assert_equals(child.treeRoot, root); | |
| 37 assert_equals(grandchild.treeRoot, root); | |
| 38 assert_equals(slot.treeRoot, root); | |
| 39 assert_equals(slotted.treeRoot, document); | |
| 40 }, 'Node.treeRoot returns a root of the tree that the node belongs to, or the sh adow root if the tree is a shadow tree.'); | |
| 41 | |
| 42 var nestedChild = document.createElement('div'); | |
| 43 var nestedRoot = grandchild.attachShadow({mode: 'open'}); | |
| 44 nestedRoot.appendChild(nestedChild); | |
| 45 | |
| 46 test(function() { | |
| 47 assert_equals(nestedRoot.treeRoot, nestedRoot); | |
| 48 assert_equals(nestedChild.treeRoot, nestedRoot); | |
| 49 }, 'Node.treeRoot works with a nested shadow tree.'); | |
| 50 | |
| 51 var detached = document.createElement('div'); | |
| 52 var detachedChild = document.createElement('div'); | |
| 53 detached.appendChild(detachedChild); | |
| 54 | |
| 55 test(function() { | |
|
kochi
2016/02/01 06:10:11
I would suggest that you put line 51-53 into this
yuzuchan
2016/02/01 08:38:51
Done.
| |
| 56 assert_equals(detached.treeRoot, detached); | |
| 57 assert_equals(detachedChild.treeRoot, detached); | |
| 58 }, 'Node.treeRoot works with a detached tree as well.'); | |
| 59 | |
| 60 var hostParent2 = document.getElementById('host-parent2'); | |
| 61 var host2 = document.getElementById('host2'); | |
| 62 var distributed = document.getElementById('distributed'); | |
| 63 var root2 = host2.createShadowRoot(); | |
| 64 var child2 = document.createElement('div'); | |
| 65 var grandchild2 = document.createElement('div'); | |
| 66 var content = document.createElement('content'); | |
| 67 content.setAttribute('select', '#distributed'); | |
| 68 child2.setAttribute('id', 'child2'); | |
| 69 grandchild2.setAttribute('id', 'grandchild2'); | |
| 70 root2.appendChild(child2); | |
| 71 child2.appendChild(grandchild2); | |
| 72 grandchild2.appendChild(content); | |
| 73 | |
| 74 test(function() { | |
|
kochi
2016/02/01 06:10:11
Same suggestion as the test above, put lines 60-72
yuzuchan
2016/02/01 08:38:51
Done.
| |
| 75 assert_equals(hostParent2.treeRoot, document); | |
| 76 assert_equals(host2.treeRoot, document); | |
| 77 assert_equals(root2.treeRoot, root2); | |
| 78 assert_equals(child2.treeRoot, root2); | |
| 79 assert_equals(grandchild2.treeRoot, root2); | |
| 80 assert_equals(content.treeRoot, root2); | |
| 81 assert_equals(distributed.treeRoot, document); | |
| 82 }, 'Node.treeRoot works with a v0 shadow tree as well.'); | |
| 83 | |
| 84 </script> | |
| OLD | NEW |