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

Unified Diff: LayoutTests/fast/dom/shadow/attr-lang-inherit.html

Issue 878743003: Use the tree of trees for the lang attributes in Shadow DOM (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update tests to reflect comments Created 5 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 | Source/core/dom/Element.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/dom/shadow/attr-lang-inherit.html
diff --git a/LayoutTests/fast/dom/shadow/attr-lang-inherit.html b/LayoutTests/fast/dom/shadow/attr-lang-inherit.html
new file mode 100644
index 0000000000000000000000000000000000000000..f93516282470345924e05d4003c7cb464d847660
--- /dev/null
+++ b/LayoutTests/fast/dom/shadow/attr-lang-inherit.html
@@ -0,0 +1,87 @@
+<!DOCTYPE html>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<style>
+#container > div {
+ border: green solid thin;
+}
+:lang(fr) { background:blue; color:white; }
+:lang(ja) { background:green; color:white; }
+</style>
+<div id="container">
+ <p>Test passes if "French" are all in blue and other text are all in green.</p>
+ <div lang="ja">
+ <div id="normal"></div>
+ <div id="distributed"><div>Distributed</div></div>
+ <div id="multiple"><div>Distributed to the youngest</div></div>
+ <div id="multilevel"><div>Multi-level Distributed</div></div>
+ <div id="older"></div>
+ <div id="redistributed"><div>Re-distributed</div></div>
+ </div>
+</div>
+<script>
+setup({ explicit_done: true });
+var fr = "rgb(0, 0, 255)";
+var ja = "rgb(0, 128, 0)";
+var style = "<style>:lang(fr) { background:blue; color:white; } :lang(ja) { background:green; color:white; }</style>";
+
+var host = document.getElementById("normal");
+createShadowRootWithInnerHtml(host, style + "<div lang=fr>French</div><div>Inherit Normally</div>");
+testLangInShadow("lang inherits into the shadow tree",
+ [[host.shadowRoot.querySelector("div"), fr],
+ [host.shadowRoot.lastChild, ja]]);
+
+host = document.getElementById("distributed");
+createShadowRootWithInnerHtml(host, style + "<div lang=fr><div>French</div><content></content></div>");
+testLangInShadow("lang of the distributed content traverses the tree of trees",
+ [[host.shadowRoot.querySelector("div"), fr],
+ [host.shadowRoot.host.firstChild, ja]]);
+
+host = document.getElementById("multiple");
+createShadowRootWithInnerHtml(host, style + "<content></content>");
+createShadowRootWithInnerHtml(host, style + "<div lang=fr><div>French</div><content></content></div>");
+testLangInShadow("lang of the distributed content traverses the tree of trees (multiple shadow roots)",
+ [[host.shadowRoot.querySelector("div"), fr],
+ [host.shadowRoot.host.firstChild, ja]]);
+
+host = document.getElementById("multilevel");
+var host2ndLevel = createShadowRootWithInnerHtml(host, "<div><content></content></div>").firstChild;
+createShadowRootWithInnerHtml(host2ndLevel, style + "<div lang=fr><div>French</div><content></content></div>");
+testLangInShadow("lang of the distributed content traverses the tree of trees (multiple levels)",
+ [[host2ndLevel.shadowRoot.querySelector("div"), fr],
+ [host.firstChild, ja]]);
+
+host = document.getElementById("older");
+createShadowRootWithInnerHtml(host, style + "<div>olderShadowRoot</div>");
+createShadowRootWithInnerHtml(host, style + "<div lang=fr><div>French</div><shadow></shadow></div>");
+testLangInShadow("lang of the older shadow root traverses the tree of trees",
+ [[host.shadowRoot.querySelector("div"), fr],
+ [host.shadowRoot.olderShadowRoot.querySelector("div"), ja]]);
+
+host = document.getElementById("redistributed");
+createShadowRootWithInnerHtml(host, style + "<div lang=fr><div>French</div><content></content></div>");
+createShadowRootWithInnerHtml(host, style + "<shadow></shadow>");
+testLangInShadow("lang of the re-distributed content traverses the tree of trees",
+ [[host.shadowRoot.olderShadowRoot.querySelector("div"), fr],
+ [host.firstChild, ja]]);
+
+function testLangInShadow(description, elementAndExpectedList) {
+ test(function () {
+ elementAndExpectedList.forEach(function (elementAndExpected) {
+ var element = elementAndExpected[0];
+ var actual = getComputedStyle(element).backgroundColor;
+ assert_equals(actual, elementAndExpected[1]);
+ });
+ }, description);
+}
+
+function createShadowRootWithInnerHtml(host, shadowHtml) {
+ var root = host.createShadowRoot();
+ root.innerHTML = shadowHtml;
+ return root;
+}
+
+if (window.testRunner)
+ container.style.display = "none";
+done();
+</script>
« no previous file with comments | « no previous file | Source/core/dom/Element.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698