OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <meta charset="utf-8"> | 4 <meta charset="utf-8"> |
5 <title>HTML Test: Styling</title> | 5 <title>HTML Test: Styling</title> |
6 <link rel="author" title="Intel" href="http://www.intel.com/"> | 6 <link rel="author" title="Intel" href="http://www.intel.com/"> |
7 <link rel="help" href="https://html.spec.whatwg.org/multipage/#styling"> | 7 <link rel="help" href="https://html.spec.whatwg.org/multipage/#styling"> |
8 <link id="style1" rel="text" title="Intel" href="./support/unmatch.css"> | 8 <link id="style1" rel="text" title="Intel" href="./support/unmatch.css"> |
9 <link id="style2" rel="alternate stylesheet" type="text/css" title="" href="
./support/emptytitle.css"> | 9 <link id="style2" rel="alternate stylesheet" type="text/css" title="" href="
./support/emptytitle.css"> |
10 <link id="style3" rel="alternate stylesheet" type="text/css" href="./support
/notitle.css"> | 10 <link id="style3" rel="alternate stylesheet" type="text/css" href="./support
/notitle.css"> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #test { | 22 #test { |
23 background-color: green; | 23 background-color: green; |
24 } | 24 } |
25 </style> | 25 </style> |
26 </head> | 26 </head> |
27 <body> | 27 <body> |
28 <div id="log"></div> | 28 <div id="log"></div> |
29 <div id="test" style="display:none">STYLING TEST</div> | 29 <div id="test" style="display:none">STYLING TEST</div> |
30 | 30 |
31 <script> | 31 <script> |
32 test(function() { | 32 /** |
33 var style = null, | 33 * Browsers may incorrectly issue requests for these resources and defer |
34 i; | 34 * definition of the `sheet` attribute until after loading is complete. |
35 for (i = 1; i < 5; i++) { | 35 * In such cases, synchronous assertions regarding the absence of |
36 style = document.getElementById("style" + i); | 36 * attributes will spuriously pass. |
37 assert_equals(style.sheet, null, "The sheet attribute of style" + i +
" should be null."); | 37 * |
38 assert_false(style.disabled, "The disabled attribute of style" + i + "
should be false."); | 38 * In order to account for this incorrect behavior (exhibited at the time |
39 } | 39 * of this writing most notably by the Chromium browser), defer the |
| 40 * assertions until the "load" event has been triggered. |
| 41 */ |
| 42 async_test(function(t) { |
| 43 window.addEventListener("load", t.step_func(function() { |
| 44 var style = null, |
| 45 i; |
| 46 for (i = 1; i < 5; i++) { |
| 47 style = document.getElementById("style" + i); |
| 48 assert_equals(style.sheet, null, "The sheet attribute of style" + i
+ " should be null."); |
| 49 assert_false(style.disabled, "The disabled attribute of style" + i +
" should be false."); |
| 50 } |
| 51 t.done(); |
| 52 })); |
40 }, "The LinkStyle interface's sheet attribute must return null; the disabl
ed attribute must be false"); | 53 }, "The LinkStyle interface's sheet attribute must return null; the disabl
ed attribute must be false"); |
41 | 54 |
42 test(function() { | 55 test(function() { |
43 var style = document.createElement("style"), | 56 var style = document.createElement("style"), |
44 link = document.createElement("link"); | 57 link = document.createElement("link"); |
45 assert_equals(style.sheet, null, "The sheet attribute of the style eleme
nt not in a document should be null."); | 58 assert_equals(style.sheet, null, "The sheet attribute of the style eleme
nt not in a document should be null."); |
46 assert_equals(link.sheet, null, "The sheet attribute of the link element
not in a document should be null."); | 59 assert_equals(link.sheet, null, "The sheet attribute of the link element
not in a document should be null."); |
47 }, "The LinkStyle interface's sheet attribute must return null if the corr
esponding element is not in a Document"); | 60 }, "The LinkStyle interface's sheet attribute must return null if the corr
esponding element is not in a Document"); |
48 | 61 |
49 test(function() { | 62 async_test(function(t) { |
50 var style = null, | 63 window.addEventListener("load", t.step_func(function() { |
51 i; | 64 var style = null, |
52 for (i = 5; i < 8; i++) { | 65 i; |
53 style = document.getElementById("style" + i); | 66 for (i = 5; i < 8; i++) { |
54 assert_true(style.sheet instanceof StyleSheet, "The sheet attribute of
style" + i + " should be a StyleSheet object."); | 67 style = document.getElementById("style" + i); |
55 assert_equals(style.disabled, style.sheet.disabled, "The disabled attr
ibute of style" + i + " should equal to the same attribute of StyleSheet."); | 68 assert_true(style.sheet instanceof StyleSheet, "The sheet attribute
of style" + i + " should be a StyleSheet object."); |
56 } | 69 assert_equals(style.disabled, style.sheet.disabled, "The disabled at
tribute of style" + i + " should equal to the same attribute of StyleSheet."); |
| 70 } |
| 71 t.done(); |
| 72 })); |
57 }, "The LinkStyle interface's sheet attribute must return StyleSheet objec
t; the disabled attribute must be same as the StyleSheet's disabled attribute"); | 73 }, "The LinkStyle interface's sheet attribute must return StyleSheet objec
t; the disabled attribute must be same as the StyleSheet's disabled attribute"); |
58 | 74 |
59 test(function() { | 75 test(function() { |
60 assert_equals(document.getElementById("style2").title, "", "The title at
tribute of style2 is incorrect."); | 76 assert_equals(document.getElementById("style2").title, "", "The title at
tribute of style2 is incorrect."); |
61 assert_equals(document.getElementById("style5").title, "", "The title at
tribute of style5 is incorrect."); | 77 assert_equals(document.getElementById("style5").title, "", "The title at
tribute of style5 is incorrect."); |
62 assert_equals(document.getElementById("style6").title, "./support/altern
ate.css", "The title attribute of style6 is incorrect."); | 78 assert_equals(document.getElementById("style6").title, "./support/altern
ate.css", "The title attribute of style6 is incorrect."); |
63 assert_equals(document.getElementById("style7").title, "./support/altern
ate.css", "The title attribute of style7 is incorrect."); | 79 assert_equals(document.getElementById("style7").title, "./support/altern
ate.css", "The title attribute of style7 is incorrect."); |
64 }, "The title must be the same as the value of the element's title content
attribute"); | 80 }, "The title must be the same as the value of the element's title content
attribute"); |
65 | 81 |
66 test(function() { | 82 test(function() { |
67 assert_equals(document.getElementById("style5").media, "", "The media at
tribute of style5 is incorrect."); | 83 assert_equals(document.getElementById("style5").media, "", "The media at
tribute of style5 is incorrect."); |
68 assert_equals(document.getElementById("style7").media, "all", "The media
attribute of style7 is incorrect."); | 84 assert_equals(document.getElementById("style7").media, "all", "The media
attribute of style7 is incorrect."); |
69 }, "The media must be the same as the value of the element's media content
attribute, or the empty string if it is omitted"); | 85 }, "The media must be the same as the value of the element's media content
attribute, or the empty string if it is omitted"); |
70 </script> | 86 </script> |
71 </body> | 87 </body> |
72 </html> | 88 </html> |
OLD | NEW |