OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <meta charset="utf-8"> | 2 <meta charset="utf-8"> |
3 <script src="../../../resources/testharness.js"></script> | 3 <script src="../../../resources/testharness.js"></script> |
4 <script src="../../../resources/testharnessreport.js"></script> | 4 <script src="../../../resources/testharnessreport.js"></script> |
5 <script src="resources/shadow-dom.js"></script> | 5 <script src="resources/shadow-dom.js"></script> |
6 <div id="container"> | 6 <div id="container"> |
7 <h2>dir=rtl inherits into shadow trees</h2> | 7 <h2>dir=rtl inherits into shadow trees</h2> |
8 <div id="dir-rtl-inherits" dir="rtl" data-dir-expected="rtl"> | 8 <div id="dir-rtl-inherits" dir="rtl" data-dir-expected="rtl"> |
9 <template> | 9 <template> |
10 <div id="target">The dir=rtl of host should inherit to shadow trees<
/div> | 10 <div id="target">The dir=rtl of host should inherit to shadow trees<
/div> |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 <shadow></shadow> | 160 <shadow></shadow> |
161 </template> | 161 </template> |
162 </div> | 162 </div> |
163 </div> | 163 </div> |
164 <script> | 164 <script> |
165 convertTemplatesToShadowRootsWithin(container); | 165 convertTemplatesToShadowRootsWithin(container); |
166 | 166 |
167 // Test dir="rtl" inherits in shadow trees | 167 // Test dir="rtl" inherits in shadow trees |
168 | 168 |
169 test(function () { | 169 test(function () { |
170 assert_direction("dir=rtl", getNodeInTreeOfTrees("dir-rtl-inherits/target"))
; | 170 assert_direction("dir=rtl", getNodeInComposedTree("dir-rtl-inherits/target")
); |
171 }, "dir=rtl inherits into shadow trees"); | 171 }, "dir=rtl inherits into shadow trees"); |
172 | 172 |
173 test(function () { | 173 test(function () { |
174 assert_direction("dir=rtl", getNodeInTreeOfTrees("dir-rtl-distributed")); | 174 assert_direction("dir=rtl", getNodeInComposedTree("dir-rtl-distributed")); |
175 }, "dir=rtl applies to the distributed content"); | 175 }, "dir=rtl applies to the distributed content"); |
176 | 176 |
177 test(function () { | 177 test(function () { |
178 assert_direction("dir=rtl", getNodeInTreeOfTrees("dir-rtl-final")); | 178 assert_direction("dir=rtl", getNodeInComposedTree("dir-rtl-final")); |
179 }, "dir=rtl applies to the distributed content with multiple shadow roots"); | 179 }, "dir=rtl applies to the distributed content with multiple shadow roots"); |
180 | 180 |
181 test(function () { | 181 test(function () { |
182 assert_direction("dir=rtl", getNodeInTreeOfTrees("dir-rtl-redistributed-mult
ilevel")); | 182 assert_direction("dir=rtl", getNodeInComposedTree("dir-rtl-redistributed-mul
tilevel")); |
183 }, "dir=rtl applies to the distributed content (multiple levels)"); | 183 }, "dir=rtl applies to the distributed content (multiple levels)"); |
184 | 184 |
185 test(function () { | 185 test(function () { |
186 assert_direction("dir=rtl", getNodeInTreeOfTrees("dir-rtl-older/target")); | 186 assert_direction("dir=rtl", getNodeInComposedTree("dir-rtl-older/target")); |
187 }, "dir=rtl applies to the content in older shadow roots"); | 187 }, "dir=rtl applies to the content in older shadow roots"); |
188 | 188 |
189 test(function () { | 189 test(function () { |
190 assert_direction("dir=rtl", getNodeInTreeOfTrees("dir-rtl-redistributed")); | 190 assert_direction("dir=rtl", getNodeInComposedTree("dir-rtl-redistributed")); |
191 }, "dir=rtl applies to the re-distributed content through older shadow roots"); | 191 }, "dir=rtl applies to the re-distributed content through older shadow roots"); |
192 | 192 |
193 // Test dir="auto" inherits in shadow trees | 193 // Test dir="auto" inherits in shadow trees |
194 // dir="auto" calculates the directionality by the first character | 194 // dir="auto" calculates the directionality by the first character |
195 | 195 |
196 test(function () { | 196 test(function () { |
197 assert_direction("English text", getNodeInTreeOfTrees("dir-auto-english")); | 197 assert_direction("English text", getNodeInComposedTree("dir-auto-english")); |
198 assert_direction("Hebrew text", getNodeInTreeOfTrees("dir-auto-hebrew")); | 198 assert_direction("Hebrew text", getNodeInComposedTree("dir-auto-hebrew")); |
199 assert_direction("Hebrew text", getNodeInTreeOfTrees("dir-auto-hebrew-span")
); | 199 assert_direction("Hebrew text", getNodeInComposedTree("dir-auto-hebrew-span"
)); |
200 }, "dir=auto the first character in the shadow trees"); | 200 }, "dir=auto the first character in the shadow trees"); |
201 | 201 |
202 test(function () { | 202 test(function () { |
203 assert_direction("English text", getNodeInTreeOfTrees("dir-auto-distributed-
english")); | 203 assert_direction("English text", getNodeInComposedTree("dir-auto-distributed
-english")); |
204 assert_direction("Hebrew text", getNodeInTreeOfTrees("dir-auto-distributed-h
ebrew")); | 204 assert_direction("Hebrew text", getNodeInComposedTree("dir-auto-distributed-
hebrew")); |
205 }, "dir=auto the first character in the distributed content"); | 205 }, "dir=auto the first character in the distributed content"); |
206 | 206 |
207 test(function () { | 207 test(function () { |
208 assert_direction("English text", getNodeInTreeOfTrees("dir-auto-final-englis
h")); | 208 assert_direction("English text", getNodeInComposedTree("dir-auto-final-engli
sh")); |
209 assert_direction("Hebrew text", getNodeInTreeOfTrees("dir-auto-final-hebrew"
)); | 209 assert_direction("Hebrew text", getNodeInComposedTree("dir-auto-final-hebrew
")); |
210 }, "dir=auto the first character in the distributed content with multiple shadow
roots"); | 210 }, "dir=auto the first character in the distributed content with multiple shadow
roots"); |
211 | 211 |
212 test(function () { | 212 test(function () { |
213 assert_direction("English text", getNodeInTreeOfTrees("dir-auto-multilevel-e
nglish")); | 213 assert_direction("English text", getNodeInComposedTree("dir-auto-multilevel-
english")); |
214 assert_direction("Hebrew text", getNodeInTreeOfTrees("dir-auto-multilevel-he
brew")); | 214 assert_direction("Hebrew text", getNodeInComposedTree("dir-auto-multilevel-h
ebrew")); |
215 }, "dir=auto the first character in the distributed content with multiple levels
of shadow roots"); | 215 }, "dir=auto the first character in the distributed content with multiple levels
of shadow roots"); |
216 | 216 |
217 test(function () { | 217 test(function () { |
218 assert_direction("English text", getNodeInTreeOfTrees("dir-auto-older-englis
h")); | 218 assert_direction("English text", getNodeInComposedTree("dir-auto-older-engli
sh")); |
219 assert_direction("Hebrew text", getNodeInTreeOfTrees("dir-auto-older-hebrew"
)); | 219 assert_direction("Hebrew text", getNodeInComposedTree("dir-auto-older-hebrew
")); |
220 }, "dir=auto the first character in the distributed content from older shadow ro
ots"); | 220 }, "dir=auto the first character in the distributed content from older shadow ro
ots"); |
221 | 221 |
222 test(function () { | 222 test(function () { |
223 assert_direction("English text", getNodeInTreeOfTrees("dir-auto-redistribute
d-english")); | 223 assert_direction("English text", getNodeInComposedTree("dir-auto-redistribut
ed-english")); |
224 assert_direction("Hebrew text", getNodeInTreeOfTrees("dir-auto-redistributed
-hebrew")); | 224 assert_direction("Hebrew text", getNodeInComposedTree("dir-auto-redistribute
d-hebrew")); |
225 }, "dir=auto the first character in the re-distributed content through older sha
dow roots"); | 225 }, "dir=auto the first character in the re-distributed content through older sha
dow roots"); |
226 | 226 |
227 function assert_direction(description, elementToTest) { | 227 function assert_direction(description, elementToTest) { |
228 elementToTest.style.webkitBorderStart = "5px solid green"; | 228 elementToTest.style.webkitBorderStart = "5px solid green"; |
229 elementToTest.style.webkitBorderEnd = "5px solid red"; | 229 elementToTest.style.webkitBorderEnd = "5px solid red"; |
230 var actualColor = document.defaultView.getComputedStyle(elementToTest).getPr
opertyValue("border-right-color"); | 230 var actualColor = document.defaultView.getComputedStyle(elementToTest).getPr
opertyValue("border-right-color"); |
231 var dirExpected = elementToTest.dataset.dirExpected; | 231 var dirExpected = elementToTest.dataset.dirExpected; |
232 switch (dirExpected) { | 232 switch (dirExpected) { |
233 case "ltr": | 233 case "ltr": |
234 assert_equals(actualColor, "rgb(255, 0, 0)", description + " should
be left-to-right"); | 234 assert_equals(actualColor, "rgb(255, 0, 0)", description + " should
be left-to-right"); |
235 break; | 235 break; |
236 case "rtl": | 236 case "rtl": |
237 assert_equals(actualColor, "rgb(0, 128, 0)", description + " should
be right-to-left"); | 237 assert_equals(actualColor, "rgb(0, 128, 0)", description + " should
be right-to-left"); |
238 break; | 238 break; |
239 default: | 239 default: |
240 break; | 240 break; |
241 } | 241 } |
242 } | 242 } |
243 | 243 |
244 if (window.testRunner) | 244 if (window.testRunner) |
245 container.style.display = "none"; | 245 container.style.display = "none"; |
246 </script> | 246 </script> |
OLD | NEW |