Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/dom/shadow/treeRoot.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/dom/shadow/treeRoot.html b/third_party/WebKit/LayoutTests/fast/dom/shadow/treeRoot.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..14158a8ff1f77586402eadf768870febe16f84ab |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/fast/dom/shadow/treeRoot.html |
| @@ -0,0 +1,84 @@ |
| +<!DOCTYPE html> |
| +<script src="../../../resources/testharness.js"></script> |
| +<script src="../../../resources/testharnessreport.js"></script> |
| +<div id="host-parent"> |
| + <div id="host"> |
| + </div> |
| + <div id="slotted"></div> |
| +</div> |
| +<div id="host-parent2"> |
| + <div id="host2"> |
| + </div> |
| + <div id="distributed" id="distributed"></div> |
| +</div> |
| + |
| +<script> |
| +var hostParent = document.getElementById('host-parent'); |
| +var host = document.getElementById('host'); |
| +var slotted = document.getElementById('slotted'); |
| +var root = host.attachShadow({mode: 'open'}); |
| +var child = document.createElement('div'); |
| +var grandchild = document.createElement('div'); |
| +var slot = document.createElement('slot'); |
| +slot.setAttribute('name', 'slot'); |
| +slotted.setAttribute('slot', 'slot'); |
| +child.setAttribute('id', 'child'); |
| +grandchild.setAttribute('id', 'grandchild'); |
| +root.appendChild(child); |
| +child.appendChild(grandchild); |
| +grandchild.appendChild(slot); |
| + |
| +test(function() { |
| + assert_equals(document.treeRoot, document); |
| + assert_equals(hostParent.treeRoot, document); |
| + assert_equals(host.treeRoot, document); |
| + assert_equals(root.treeRoot, root); |
| + assert_equals(child.treeRoot, root); |
| + assert_equals(grandchild.treeRoot, root); |
| + assert_equals(slot.treeRoot, root); |
| + assert_equals(slotted.treeRoot, document); |
| +}, 'Node.treeRoot returns a root of the tree that the node belongs to, or the shadow root if the tree is a shadow tree.'); |
| + |
| +var nestedChild = document.createElement('div'); |
| +var nestedRoot = grandchild.attachShadow({mode: 'open'}); |
| +nestedRoot.appendChild(nestedChild); |
| + |
| +test(function() { |
| + assert_equals(nestedRoot.treeRoot, nestedRoot); |
| + assert_equals(nestedChild.treeRoot, nestedRoot); |
| +}, 'Node.treeRoot works with a nested shadow tree.'); |
| + |
| +var detached = document.createElement('div'); |
| +var detachedChild = document.createElement('div'); |
| +detached.appendChild(detachedChild); |
| + |
| +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.
|
| + assert_equals(detached.treeRoot, detached); |
| + assert_equals(detachedChild.treeRoot, detached); |
| +}, 'Node.treeRoot works with a detached tree as well.'); |
| + |
| +var hostParent2 = document.getElementById('host-parent2'); |
| +var host2 = document.getElementById('host2'); |
| +var distributed = document.getElementById('distributed'); |
| +var root2 = host2.createShadowRoot(); |
| +var child2 = document.createElement('div'); |
| +var grandchild2 = document.createElement('div'); |
| +var content = document.createElement('content'); |
| +content.setAttribute('select', '#distributed'); |
| +child2.setAttribute('id', 'child2'); |
| +grandchild2.setAttribute('id', 'grandchild2'); |
| +root2.appendChild(child2); |
| +child2.appendChild(grandchild2); |
| +grandchild2.appendChild(content); |
| + |
| +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.
|
| + assert_equals(hostParent2.treeRoot, document); |
| + assert_equals(host2.treeRoot, document); |
| + assert_equals(root2.treeRoot, root2); |
| + assert_equals(child2.treeRoot, root2); |
| + assert_equals(grandchild2.treeRoot, root2); |
| + assert_equals(content.treeRoot, root2); |
| + assert_equals(distributed.treeRoot, document); |
| +}, 'Node.treeRoot works with a v0 shadow tree as well.'); |
| + |
| +</script> |