OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../resources/testharness.js"></script> |
| 3 <script src="../resources/testharnessreport.js"></script> |
| 4 <script src="resources/shadow-dom.js"></script> |
| 5 <body> |
| 6 <div id="host"> |
| 7 <template mode-data="open"> |
| 8 <link rel="stylesheet" title="hello1" href="data:text/css,#shadowChild1 {
color: green }"> |
| 9 <link rel="stylesheet" title="hello2" href="data:text/css,#shadowChild2 {
color: green }"> |
| 10 <link rel="alternate stylesheet" title="world1" href="data:text/css,#shado
wChild3 { color: green }"> |
| 11 <div id="shadowChild1"></div> |
| 12 <div id="shadowChild2"></div> |
| 13 <div id="shadowChild3"></div> |
| 14 <div id="shadowChild4"></div> |
| 15 </template> |
| 16 </div> |
| 17 <div id="bodyChild1"></div> |
| 18 <div id="bodyChild2"></div> |
| 19 <script>convertTemplatesToShadowRootsWithin(host);</script> |
| 20 <link rel="stylesheet" title="preferred1" href="data:text/css,#bodyChild1 { co
lor: green }"> |
| 21 <link rel="stylesheet" title="preferred2" href="data:text/css,#bodyChild2 { co
lor: green }"> |
| 22 </body> |
| 23 <script> |
| 24 function colorFor(elem) { |
| 25 return document.defaultView.getComputedStyle(elem, '').color; |
| 26 } |
| 27 |
| 28 test(() => { |
| 29 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.'); |
| 30 assert_equals(colorFor(bodyChild2), 'rgb(0, 0, 0)', 'A non-preferred styleshee
t should not be used.'); |
| 31 |
| 32 assert_equals(colorFor(host.shadowRoot.querySelector('#shadowChild2')), 'rgb(0
, 128, 0)', 'A title attribute should be ignored in a shadow tree.'); |
| 33 assert_equals(colorFor(host.shadowRoot.querySelector('#shadowChild2')), 'rgb(0
, 128, 0)', 'A title attribute should be ignored in a shadow tree. Both hello1 a
nd hello2 are enabled in a shadow tree.'); |
| 34 // Setting document.selectedStyleSheetSetName currently has no effect to activ
ate alternate stylesheets. We can not test to select alternate stylesheet in a s
hadow tree. |
| 35 assert_equals(colorFor(host.shadowRoot.querySelector('#shadowChild3')), 'rgb(0
, 0, 0)', 'An alternate stylesheet should be disabled by default.'); |
| 36 }, '<link rel="stylesheet"> should work in a connected shadow tree.'); |
| 37 </script> |
OLD | NEW |