|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=940229 |
|
5 --> |
|
6 <head> |
|
7 <title>Test handling extra inherit/initial/unset in CSS declarations (Bug 940229)</title> |
|
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <script type="text/javascript" src="property_database.js"></script> |
|
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
11 </head> |
|
12 <body> |
|
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=940229">Mozilla Bug 940229</a> |
|
14 <p id="display"></p> |
|
15 <div id="content" style="display: none"> |
|
16 |
|
17 <div id="testnode"></div> |
|
18 |
|
19 </div> |
|
20 <pre id="test"> |
|
21 <script class="testbody" type="text/javascript"> |
|
22 |
|
23 /* |
|
24 * Inspired by mistake in quotes noticed while reviewing bug 189519. |
|
25 */ |
|
26 |
|
27 var gPropsNeedComma = { |
|
28 "font": true, |
|
29 "font-family": true, |
|
30 "voice-family": true, |
|
31 }; |
|
32 |
|
33 var gElement = document.getElementById("testnode"); |
|
34 var gDeclaration = gElement.style; |
|
35 |
|
36 function test_property(property) |
|
37 { |
|
38 var info = gCSSProperties[property]; |
|
39 |
|
40 var delim = (property in gPropsNeedComma) ? ", " : " "; |
|
41 |
|
42 function test_value_pair(relation, val1, val2, extraval) { |
|
43 var decl = property + ": " + val1 + delim + val2; |
|
44 gElement.setAttribute("style", decl); |
|
45 if ("subproperties" in info) { |
|
46 for (idx in info.subproperties) { |
|
47 var subprop = info.subproperties[idx]; |
|
48 is(gDeclaration.getPropertyValue(subprop), "", |
|
49 ["expected", extraval, "ignored", relation, "value in", |
|
50 "'" + decl + "'", "when looking at subproperty", |
|
51 "'" + subprop + "'"].join(" ")); |
|
52 } |
|
53 } else { |
|
54 is(gDeclaration.getPropertyValue(property), "", |
|
55 ["expected", extraval, "ignored", relation, "value in", |
|
56 "'" + decl + "'"].join(" ")); |
|
57 } |
|
58 } |
|
59 |
|
60 function test_value(value) { |
|
61 test_value_pair("after", value, "inherit", "inherit"); |
|
62 test_value_pair("after", value, "initial", "initial"); |
|
63 test_value_pair("after", value, "unset", "unset"); |
|
64 test_value_pair("before", "inherit", value, "inherit"); |
|
65 test_value_pair("before", "initial", value, "initial"); |
|
66 test_value_pair("before", "unset", value, "unset"); |
|
67 } |
|
68 |
|
69 var idx; |
|
70 for (idx in info.initial_values) |
|
71 test_value(info.initial_values[idx]); |
|
72 for (idx in info.other_values) |
|
73 test_value(info.other_values[idx]); |
|
74 } |
|
75 |
|
76 SimpleTest.waitForExplicitFinish(); |
|
77 SimpleTest.requestLongerTimeout(4); |
|
78 |
|
79 function start_test() { |
|
80 for (var prop in gCSSProperties) { |
|
81 test_property(prop); |
|
82 } |
|
83 SimpleTest.finish(); |
|
84 } |
|
85 |
|
86 // Turn off CSS error reporting for this test, since it's a bit expensive, |
|
87 // and we're expecting to generate tons and tons of parse errors here. |
|
88 SpecialPowers.pushPrefEnv({ "set": [["layout.css.report_errors", false]] }, |
|
89 start_test); |
|
90 |
|
91 </script> |
|
92 </pre> |
|
93 </body> |
|
94 </html> |