Bug 1839315: part 4) Link from `SheetLoadData::mWasAlternate` to spec. r=emilio DONTBUILD
[gecko.git] / layout / style / test / test_property_database.html
blobba04ec341aeb58577054ae9cb8b8814ab6f10a0a
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 -->
5 <head>
6 <title>Test that property_database.js contains all supported CSS properties</title>
7 <script src="/tests/SimpleTest/SimpleTest.js"></script>
8 <script type="text/javascript" src="css_properties.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 <p id="display"></p>
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 /** Test that property_database.js contains all supported CSS properties **/
25 * Here we are testing the hand-written property_database.js against
26 * the autogenerated css_properties.js to make sure that everything in
27 * css_properties.js is in property_database.js.
29 * This prevents CSS properties from being added to the code without
30 * also being put under the minimal test coverage provided by the tests
31 * that use property_database.js.
34 for (var idx in gLonghandProperties) {
35 var prop = gLonghandProperties[idx];
36 if (prop.pref && !IsCSSPropertyPrefEnabled(prop.pref)) {
37 continue;
39 var present = prop.name in gCSSProperties;
40 ok(present,
41 "'" + prop.name + "' listed in gCSSProperties");
42 if (present) {
43 is(gCSSProperties[prop.name].type, CSS_TYPE_LONGHAND,
44 "'" + prop.name + "' listed as CSS_TYPE_LONGHAND");
45 is(gCSSProperties[prop.name].domProp, prop.prop,
46 "'" + prop.name + "' listed with correct DOM property name");
49 for (var idx in gShorthandProperties) {
50 var prop = gShorthandProperties[idx];
51 if (prop.pref && !IsCSSPropertyPrefEnabled(prop.pref)) {
52 continue;
54 if (prop.name == "all") {
55 // "all" isn't listed in property_database.js.
56 continue;
58 var present = prop.name in gCSSProperties;
59 ok(present,
60 "'" + prop.name + "' listed in gCSSProperties");
61 if (present) {
62 ok(gCSSProperties[prop.name].type == CSS_TYPE_TRUE_SHORTHAND ||
63 gCSSProperties[prop.name].type == CSS_TYPE_LEGACY_SHORTHAND ||
64 gCSSProperties[prop.name].type == CSS_TYPE_SHORTHAND_AND_LONGHAND,
65 "'" + prop.name + "' listed as CSS_TYPE_TRUE_SHORTHAND, CSS_TYPE_LEGACY_SHORTHAND, or CSS_TYPE_SHORTHAND_AND_LONGHAND");
66 ok(gCSSProperties[prop.name].domProp == prop.prop,
67 "'" + prop.name + "' listed with correct DOM property name");
70 for (var idx in gShorthandPropertiesLikeLonghand) {
71 var prop = gShorthandPropertiesLikeLonghand[idx];
72 if (prop.pref && !IsCSSPropertyPrefEnabled(prop.pref)) {
73 continue;
75 var present = prop.name in gCSSProperties;
76 ok(present,
77 "'" + prop.name + "' listed in gCSSProperties");
78 if (present) {
79 ok(gCSSProperties[prop.name].type == CSS_TYPE_SHORTHAND_AND_LONGHAND,
80 "'" + prop.name + "' listed as CSS_TYPE_SHORTHAND_AND_LONGHAND");
81 ok(gCSSProperties[prop.name].domProp == prop.prop,
82 "'" + prop.name + "' listed with correct DOM property name");
87 * Test that all shorthand properties have a subproperty list and all
88 * longhand properties do not.
90 for (var prop in gCSSProperties) {
91 var entry = gCSSProperties[prop];
92 if (entry.pref && !IsCSSPropertyPrefEnabled(entry.pref)) {
93 continue;
95 if (entry.type == CSS_TYPE_LONGHAND) {
96 ok(!("subproperties" in entry),
97 "longhand property '" + prop + "' must not have subproperty list");
98 } else if (entry.type == CSS_TYPE_TRUE_SHORTHAND ||
99 entry.type == CSS_TYPE_SHORTHAND_AND_LONGHAND) {
100 ok("subproperties" in entry,
101 "shorthand property '" + prop + "' must have subproperty list");
104 if ("subproperties" in entry) {
105 var good = true;
106 if (entry.subproperties.length < 1) {
107 info("subproperty list for '" + prop + "' is empty");
108 good = false;
110 for (var idx in entry.subproperties) {
111 var subprop = entry.subproperties[idx];
112 if (!(subprop in gCSSProperties)) {
113 info("subproperty list for '" + prop + "' lists nonexistent subproperty '" + subprop + "'");
114 good = false;
117 ok(good, "property '" + prop + "' has a good subproperty list");
120 ok("initial_values" in entry && entry.initial_values.length >= 1,
121 "must have initial values for property '" + prop + "'");
122 ok("other_values" in entry && entry.other_values.length >= 1,
123 "must have non-initial values for property '" + prop + "'");
127 * Test that only longhand properties or its aliases are listed as logical
128 * properties.
130 for (var prop in gCSSProperties) {
131 var entry = gCSSProperties[prop];
132 if (entry.logical) {
133 ok(entry.type == CSS_TYPE_LONGHAND ||
134 (entry.alias_for && gCSSProperties[entry.alias_for].logical),
135 "property '" + prop + "' is listed as CSS_TYPE_LONGHAND or is an alias due to it " +
136 "being a logical property");
141 * Test that axis is only specified for logical properties.
143 for (var prop in gCSSProperties) {
144 var entry = gCSSProperties[prop];
145 if (entry.axis) {
146 ok(entry.logical,
147 "property '" + prop + "' is listed as an logical property due to its " +
148 "being listed as an axis-related property");
153 * Test that DOM properties match the expected rules.
155 for (var prop in gCSSProperties) {
156 var entry = gCSSProperties[prop];
157 var expectedDOMProp = prop.replace(/-([a-z])/g,
158 function(m, p1, offset, str) {
159 return p1.toUpperCase();
161 if (expectedDOMProp == "float") {
162 expectedDOMProp = "cssFloat";
163 } else if (prop.startsWith("-webkit")) {
164 // Our DOM accessors for webkit-prefixed properties start with lowercase w,
165 // not uppercase like standard DOM accessors.
166 expectedDOMProp = expectedDOMProp.replace(/^W/, "w");
168 is(entry.domProp, expectedDOMProp, "DOM property for " + prop);
170 </script>
171 </pre>
172 </body>
173 </html>