Bug 1839315: part 4) Link from `SheetLoadData::mWasAlternate` to spec. r=emilio DONTBUILD
[gecko.git] / layout / style / test / test_property_syntax_errors.html
blob1e3f3820362e2973c74ba4a78052983d5fabbd80
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 -->
5 <head>
6 <title>Test that we reject syntax errors listed in property_database.js</title>
7 <script src="/tests/SimpleTest/SimpleTest.js"></script>
8 <script type="text/javascript" src="property_database.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
10 </head>
11 <body onload="run()">
12 <p id="display"></p>
13 <iframe id="quirks" src="data:text/html,<div id='testnode'></div>"></iframe>
14 <div id="content" style="display: none">
16 <div id="testnode"></div>
18 </div>
19 <pre id="test">
20 <script class="testbody" type="text/javascript">
22 SimpleTest.waitForExplicitFinish();
23 SimpleTest.requestLongerTimeout(4);
25 function check_not_accepted(decl, property, info, badval)
27 decl.setProperty(property, badval, "");
29 is(decl.getPropertyValue(property), "",
30 "invalid value '" + badval + "' not accepted for '" + property +
31 "' property");
33 if ("subproperties" in info) {
34 for (var sidx in info.subproperties) {
35 var subprop = info.subproperties[sidx];
36 is(decl.getPropertyValue(subprop), "",
37 "invalid value '" + badval + "' not accepted for '" + property +
38 "' property when testing subproperty '" + subprop + "'");
42 decl.removeProperty(property);
45 function check_value_balanced(decl, property, badval)
47 var goodProp =
48 (property == "background-color") ? "color" : "background-color";
49 decl.cssText = goodProp + ": red; " + property + ": " + badval + "; " +
50 goodProp + ": green";
51 is(decl.getPropertyValue(goodProp), "green",
52 "invalid value '" + property + ": " + badval +
53 "' is balanced and does not lead to parsing errors afterwards");
54 decl.cssText = "";
57 function check_value_unbalanced(decl, property, badval)
59 var goodProp =
60 (property == "background-color") ? "color" : "background-color";
61 decl.cssText = goodProp + ": green; " + property + ": " + badval + "; " +
62 goodProp + ": red";
63 is(decl.getPropertyValue(goodProp), "green",
64 "invalid value '" + property + ": " + badval +
65 "' is unbalanced and absorbs what follows it");
66 decl.cssText = "";
69 function check_empty_value_rejected(decl, emptyval, property)
71 var goodProp =
72 (property == "background-color") ? "color" : "background-color";
73 decl.cssText = goodProp + ": red; " + property + ":" + emptyval + "; " +
74 goodProp + ": green";
75 is(decl.length, 1,
76 "empty value '" + property + ":" + emptyval +
77 "' is not accepted");
78 is(decl.getPropertyValue(goodProp), "green",
79 "empty value '" + property + ":" + emptyval +
80 "' is balanced and does not lead to parsing errors afterwards");
81 decl.cssText = "";
84 function run()
86 var gDeclaration = document.getElementById("testnode").style;
87 var quirksFrame = document.getElementById("quirks");
88 var wrappedFrame = SpecialPowers.wrap(quirksFrame);
89 var gQuirksDeclaration = wrappedFrame.contentDocument
90 .getElementById("testnode").style;
92 for (var property in gCSSProperties) {
93 var info = gCSSProperties[property];
95 check_empty_value_rejected(gDeclaration, "", property);
96 check_empty_value_rejected(gDeclaration, " ", property);
98 for (var idx in info.invalid_values) {
99 check_not_accepted(gDeclaration, property, info,
100 info.invalid_values[idx]);
101 check_not_accepted(gQuirksDeclaration, property, info,
102 info.invalid_values[idx]);
103 check_value_balanced(gDeclaration, property,
104 info.invalid_values[idx]);
107 if ("quirks_values" in info) {
108 for (var quirkval in info.quirks_values) {
109 var standardval = info.quirks_values[quirkval];
110 check_not_accepted(gDeclaration, property, info, quirkval);
111 check_value_balanced(gDeclaration, property, quirkval);
113 gQuirksDeclaration.setProperty(property, quirkval, "");
114 gDeclaration.setProperty(property, standardval, "");
115 var quirkret = gQuirksDeclaration.getPropertyValue(property);
116 var standardret = gDeclaration.getPropertyValue(property);
117 isnot(quirkret, "", property + ": " + quirkval +
118 " should be accepted in quirks mode");
119 is(quirkret, standardret, property + ": " + quirkval + " result");
121 if ("subproperties" in info) {
122 for (var sidx in info.subproperties) {
123 var subprop = info.subproperties[sidx];
124 var quirksub = gQuirksDeclaration.getPropertyValue(subprop);
125 var standardsub = gDeclaration.getPropertyValue(subprop);
126 isnot(quirksub, "", property + ": " + quirkval +
127 " should be accepted in quirks mode" +
128 " when testing subproperty " + subprop);
129 is(quirksub, standardsub, property + ": " + quirkval + " result" +
130 " when testing subproperty " + subprop);
134 gQuirksDeclaration.removeProperty(property);
135 gDeclaration.removeProperty(property);
139 for (var idx in info.unbalanced_values) {
140 check_not_accepted(gDeclaration, property, info,
141 info.invalid_values[idx]);
142 check_not_accepted(gQuirksDeclaration, property, info,
143 info.invalid_values[idx]);
144 check_value_unbalanced(gDeclaration, property,
145 info.unbalanced_values[idx]);
149 SimpleTest.finish();
152 </script>
153 </pre>
154 </body>
155 </html>