Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/shadow/treeRoot.html

Issue 1642503002: Implement Node.treeRoot (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change return type and clean up the layout test Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webexposed/element-instance-property-listing-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..184cdcb78b5d71e39d5d3b46f9438135d62fc2a2
--- /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.');
+
+test(function() {
+ var nestedChild = document.createElement('div');
+ var nestedRoot = grandchild.attachShadow({mode: 'open'});
+ nestedRoot.appendChild(nestedChild);
+
+ assert_equals(nestedRoot.treeRoot, nestedRoot);
+ assert_equals(nestedChild.treeRoot, nestedRoot);
+}, 'Node.treeRoot works with a nested shadow tree.');
+
+test(function() {
+ var detached = document.createElement('div');
+ var detachedChild = document.createElement('div');
+ detached.appendChild(detachedChild);
+
+ assert_equals(detached.treeRoot, detached);
+ assert_equals(detachedChild.treeRoot, detached);
+}, 'Node.treeRoot works with a detached tree as well.');
+
+test(function() {
+ 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);
+
+ 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>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webexposed/element-instance-property-listing-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698