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="preferred1" href="data:text/css,#shadowChild 1 { color: green }"> | |
9 <link rel="stylesheet" title="title1" href="data:text/css,#shadowChild2 { color: green }"> | |
10 <link rel="alternate stylesheet" title="prefered1" href="data:text/css,#sh adowChild3 { color: green }"> | |
11 <link rel="alternate stylesheet" title="title1" href="data:text/css,#shado wChild4 { color: green }"> | |
12 <div id="shadowChild1"></div> | |
13 <div id="shadowChild2"></div> | |
14 <div id="shadowChild3"></div> | |
15 <div id="shadowChild4"></div> | |
16 </template> | |
17 </div> | |
18 <div id="bodyChild1"></div> | |
19 <div id="bodyChild2"></div> | |
20 <script>convertTemplatesToShadowRootsWithin(host);</script> | |
21 <link rel="stylesheet" title="preferred1" href="data:text/css,#bodyChild1 { co lor: green }"> | |
22 <link rel="stylesheet" title="non-preferred" href="data:text/css,#bodyChild2 { color: green }"> | |
23 </body> | |
24 <script> | |
25 function colorFor(elem) { | |
26 return document.defaultView.getComputedStyle(elem, '').color; | |
27 } | |
28 | |
29 test(() => { | |
30 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.'); | |
31 assert_equals(colorFor(bodyChild2), 'rgb(0, 0, 0)', 'A non-preferred styleshee t should not be used.'); | |
32 | |
33 assert_equals(colorFor(host.shadowRoot.querySelector('#shadowChild1')), 'rgb(0 , 128, 0)', 'A title attribute should be ignored in a shadow tree.'); | |
34 assert_equals(colorFor(host.shadowRoot.querySelector('#shadowChild2')), 'rgb(0 , 128, 0)', 'A title attribute should be ignored in a shadow tree.'); | |
35 assert_equals(colorFor(host.shadowRoot.querySelector('#shadowChild3')), 'rgb(0 , 0, 0)', 'An alternate stylesheet should be disabled in a shadow tree.'); | |
36 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.
| |
37 }, '<link rel="stylesheet"> should work in a connected shadow tree.'); | |
38 </script> | |
OLD | NEW |