Index: third_party/WebKit/LayoutTests/shadow-dom/link-title.html |
diff --git a/third_party/WebKit/LayoutTests/shadow-dom/link-title.html b/third_party/WebKit/LayoutTests/shadow-dom/link-title.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a11bfc47b3fb450ca0f5c81c3fdacf40ec13fba1 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/shadow-dom/link-title.html |
@@ -0,0 +1,38 @@ |
+<!DOCTYPE html> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<script src="resources/shadow-dom.js"></script> |
+<body> |
+ <div id="host"> |
+ <template mode-data="open"> |
+ <link rel="stylesheet" title="preferred1" href="data:text/css,#shadowChild1 { color: green }"> |
+ <link rel="stylesheet" title="title1" href="data:text/css,#shadowChild2 { color: green }"> |
+ <link rel="alternate stylesheet" title="prefered1" href="data:text/css,#shadowChild3 { color: green }"> |
+ <link rel="alternate stylesheet" title="title1" href="data:text/css,#shadowChild4 { color: green }"> |
+ <div id="shadowChild1"></div> |
+ <div id="shadowChild2"></div> |
+ <div id="shadowChild3"></div> |
+ <div id="shadowChild4"></div> |
+ </template> |
+ </div> |
+ <div id="bodyChild1"></div> |
+ <div id="bodyChild2"></div> |
+ <script>convertTemplatesToShadowRootsWithin(host);</script> |
+ <link rel="stylesheet" title="preferred1" href="data:text/css,#bodyChild1 { color: green }"> |
+ <link rel="stylesheet" title="non-preferred" href="data:text/css,#bodyChild2 { color: green }"> |
+</body> |
+<script> |
+function colorFor(elem) { |
+ return document.defaultView.getComputedStyle(elem, '').color; |
+} |
+ |
+test(() => { |
+ assert_equals(colorFor(bodyChild1), 'rgb(0, 128, 0)', 'A link in a shadow tree does not have any effect on the preferred stylesheet on a document tree.'); |
+ assert_equals(colorFor(bodyChild2), 'rgb(0, 0, 0)', 'A non-preferred stylesheet should not be used.'); |
+ |
+ assert_equals(colorFor(host.shadowRoot.querySelector('#shadowChild1')), 'rgb(0, 128, 0)', 'A title attribute should be ignored in a shadow tree.'); |
+ assert_equals(colorFor(host.shadowRoot.querySelector('#shadowChild2')), 'rgb(0, 128, 0)', 'A title attribute should be ignored in a shadow tree.'); |
+ assert_equals(colorFor(host.shadowRoot.querySelector('#shadowChild3')), 'rgb(0, 0, 0)', 'An alternate stylesheet should be disabled in a shadow tree.'); |
+ assert_equals(colorFor(host.shadowRoot.querySelector('#shadowChild4')), 'rgb(0, 0, 0)', 'An alternate stylesheet should be disabled in a shadow tree.'); |
rune
2016/08/03 08:55:29
Nit: these are really separate test()s. testharnes
hayato
2016/08/04 03:58:15
Done. I have split this into 3 test()s.
|
+}, '<link rel="stylesheet"> should work in a connected shadow tree.'); |
+</script> |