OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <!-- |
| 3 Distributed under both the W3C Test Suite License [1] and the W3C |
| 4 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the |
| 5 policies and contribution forms [3]. |
| 6 |
| 7 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license |
| 8 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license |
| 9 [3] http://www.w3.org/2004/10/27-testcases |
| 10 --> |
| 11 <html> |
| 12 <head> |
| 13 <title>Shadow DOM Test: A_06_00_02</title> |
| 14 <link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"> |
| 15 <link rel="help" href="http://www.w3.org/TR/2013/WD-shadow-dom-20130514/#styles"
> |
| 16 <meta name="assert" content="Styles: CSS rules declared in an enclosing tree mus
t be applied in a shadow tree if apply-author-styles flag is set to true for thi
s tree"> |
| 17 <script src="../../../../resources/testharness.js"></script> |
| 18 <script src="../../../../resources/testharnessreport.js"></script> |
| 19 <script src="../testcommon.js"></script> |
| 20 <link rel="stylesheet" href="../../../../resources/testharness.css"> |
| 21 </head> |
| 22 <body> |
| 23 <div id="log"></div> |
| 24 <script> |
| 25 //test apply-author-styles flag of ShadowRoot object |
| 26 test(unit(function (ctx) { |
| 27 |
| 28 var d = newRenderedHTMLDocument(ctx); |
| 29 |
| 30 d.head.innerHTML = '<style>' + |
| 31 '.invis {' + |
| 32 'display:none;' + |
| 33 '}' + |
| 34 '</style>'; |
| 35 |
| 36 var host = d.createElement('div'); |
| 37 d.body.appendChild(host); |
| 38 |
| 39 //Shadow root to play with |
| 40 var s = host.createShadowRoot(); |
| 41 s.applyAuthorStyles = true; |
| 42 |
| 43 var div1 = d.createElement('div'); |
| 44 div1.innerHTML ='<span id="shd" class="invis">This is the shadow tree</s
pan>'; |
| 45 s.appendChild(div1); |
| 46 |
| 47 //apply-author-styles flag is set to true. Invisible style should be app
lied |
| 48 assert_equals(s.querySelector('#shd').offsetTop, 0, |
| 49 'CSS styles declared in enclosing tree must be applied in a shadow tree
' + |
| 50 'if the apply-author-styles flag is set to true'); |
| 51 |
| 52 |
| 53 }), 'A_06_00_02_T01'); |
| 54 |
| 55 |
| 56 //test apply-author-styles flag in a nested tree (set it) |
| 57 test(unit(function (ctx) { |
| 58 |
| 59 var d = newRenderedHTMLDocument(ctx); |
| 60 |
| 61 d.head.innerHTML = '<style>' + |
| 62 '.invis {' + |
| 63 'display:none;' + |
| 64 '}' + |
| 65 '</style>'; |
| 66 |
| 67 var host = d.createElement('div'); |
| 68 d.body.appendChild(host); |
| 69 |
| 70 //Shadow root to play with |
| 71 var s1 = host.createShadowRoot(); |
| 72 s1.applyAuthorStyles = true; |
| 73 |
| 74 var div1 = d.createElement('div'); |
| 75 div1.innerHTML = '<span id="shd1" class="invis">This is an old shadow tr
ee</span>'; |
| 76 s1.appendChild(div1); |
| 77 |
| 78 //younger tree |
| 79 var s2 = host.createShadowRoot(); |
| 80 s2.applyAuthorStyles = true; |
| 81 var div1 = d.createElement('div'); |
| 82 div1.innerHTML = '<span id="shd2" class="invis">This is a young shadow t
ree</span>' + |
| 83 '<shadow><span id="shd3" class="invis">This is the shadow tree f
allback content</span></shadow>'; |
| 84 s2.appendChild(div1); |
| 85 |
| 86 |
| 87 //apply-author-styles flag is set to true. Invisible style should be app
lied |
| 88 //shd1 and shd2 should be invisible. sh3 invisible too because the tree
should be active |
| 89 assert_equals(s1.querySelector('#shd1').offsetTop, 0, |
| 90 'Point 1: CSS styles declared in enclosing tree must be applied in a sh
adow tree ' + |
| 91 'if the apply-author-styles flag is set to true'); |
| 92 assert_equals(s2.querySelector('#shd2').offsetTop, 0, |
| 93 'Point 2: CSS styles declared in enclosing tree must be applied in a
shadow tree ' + |
| 94 'if the apply-author-styles flag is set to true'); |
| 95 assert_equals(s2.querySelector('#shd3').offsetTop, 0, |
| 96 'Fallback content shouldn\'t be rendered for active tree'); |
| 97 |
| 98 |
| 99 }), 'A_06_00_02_T02'); |
| 100 |
| 101 |
| 102 |
| 103 //test different apply-author-styles flag values in a nested young and old trees |
| 104 test(unit(function (ctx) { |
| 105 |
| 106 var d = newRenderedHTMLDocument(ctx); |
| 107 |
| 108 d.head.innerHTML = '<style>' + |
| 109 '.invis {' + |
| 110 'display:none;' + |
| 111 '}' + |
| 112 '</style>'; |
| 113 |
| 114 var host = d.createElement('div'); |
| 115 d.body.appendChild(host); |
| 116 |
| 117 //Shadow root to play with |
| 118 var s1 = host.createShadowRoot(); |
| 119 s1.applyAuthorStyles = true; |
| 120 |
| 121 var div1 = d.createElement('div'); |
| 122 div1.innerHTML = '<span id="shd1" class="invis">This is an old shadow tr
ee</span>'; |
| 123 s1.appendChild(div1); |
| 124 |
| 125 //younger tree |
| 126 var s2 = host.createShadowRoot(); |
| 127 //applyAuthorStyles false by default |
| 128 var div1 = d.createElement('div'); |
| 129 div1.innerHTML = '<span id="shd2" class="invis">This is a young shadow t
ree</span>' + |
| 130 '<shadow><span id="shd3" class="invis">This is the shadow tree f
allback content</span></shadow>'; |
| 131 s2.appendChild(div1); |
| 132 |
| 133 |
| 134 //apply-author-styles flag is set to true. Invisible style should be app
lied |
| 135 //shd1 and shd2 should be invisible. sh3 invisible too because the tree
should be active |
| 136 assert_equals(s1.querySelector('#shd1').offsetTop, 0, |
| 137 'Point 1: CSS styles declared in enclosing tree must be applied in a sh
adow tree ' + |
| 138 'if the apply-author-styles flag is set to true'); |
| 139 assert_true(s2.querySelector('#shd2').offsetTop > 0, |
| 140 'Point 2: CSS styles declared in enclosing tree must be applied in a
shadow tree ' + |
| 141 'if the apply-author-styles flag is set to true'); |
| 142 assert_equals(s2.querySelector('#shd3').offsetTop, 0, |
| 143 'Fallback content shouldn\'t be rendered for active tree'); |
| 144 |
| 145 |
| 146 }), 'A_06_00_02_T03'); |
| 147 </script> |
| 148 </body> |
| 149 </html> |
OLD | NEW |