Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script src="../../../resources/testharness.js"></script> | |
| 3 <script src="../../../resources/testharnessreport.js"></script> | |
| 4 <style> | |
| 5 #container > div { | |
| 6 border: green solid thin; | |
| 7 } | |
| 8 :lang(fr) { background:blue; color:white; } | |
| 9 :lang(ja) { background:green; color:white; } | |
| 10 </style> | |
| 11 <div id="container" lang="ja"> | |
| 12 <div id="normal"></div> | |
| 13 <div id="distributed"><div>Distributed</div></div> | |
| 14 </div> | |
| 15 <script> | |
| 16 setup({ explicit_done: true }); | |
| 17 var fr = "rgb(0, 0, 255)"; | |
| 18 var ja = "rgb(0, 128, 0)"; | |
| 19 var style = "<style>:lang(fr) { background:blue; color:white; } :lang(ja) { back ground:green; color:white; }</style>"; | |
| 20 | |
| 21 testLangInShadow("lang inherits into shadow tree", | |
| 22 document.getElementById("normal"), | |
| 23 style + "<div lang='fr'>French</div><div>Inherit</div>", | |
| 24 [[function (root) { return root.lastChild.previousSibling; }, fr], | |
|
hayato
2015/01/28 09:56:12
You can use shadowRoot.querySelector(..) to get th
kojii
2015/01/29 11:05:24
Done.
| |
| 25 [function (root) { return root.lastChild; }, ja]]); | |
| 26 | |
| 27 testLangInShadow("lang of distributed content traverses tree of trees recursivel y", | |
|
hayato
2015/01/28 09:56:12
"Recursively" is misleading because this test only
kojii
2015/01/29 11:05:24
Added:
- Multiple shadow roots to one host
- Multi
| |
| 28 document.getElementById("distributed"), | |
| 29 style + "<div lang='fr'><div>French</div><content></content></div>", | |
| 30 [[function (root) { return root.lastChild.firstChild; }, fr], | |
| 31 [function (root) { return root.host.firstChild; }, ja]]); | |
| 32 | |
| 33 function testLangInShadow(description, host, shadowHtml, elementAndExpectedList) { | |
| 34 var root = host.createShadowRoot(); | |
| 35 root.innerHTML = shadowHtml; | |
| 36 test(function () { | |
| 37 elementAndExpectedList.forEach(function (elementAndExpected) { | |
| 38 var element = elementAndExpected[0]; | |
| 39 if (typeof(element) === "function") | |
|
hayato
2015/01/28 09:56:12
In this test, elementAndExpected[0] is always a fu
kojii
2015/01/29 11:05:23
Done.
| |
| 40 element = element(root); | |
| 41 var actual = getComputedStyle(element).backgroundColor; | |
| 42 assert_equals(actual, elementAndExpected[1]); | |
| 43 }); | |
| 44 }, description); | |
| 45 } | |
| 46 | |
| 47 if (window.testRunner) | |
| 48 container.style.display = "none"; | |
| 49 done(); | |
| 50 </script> | |
| OLD | NEW |