Bug 1839315: part 4) Link from `SheetLoadData::mWasAlternate` to spec. r=emilio DONTBUILD
[gecko.git] / layout / style / test / test_inherit_storage.html
bloba9587d34d9ec641af01fa75c017aa58a59665583
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=375363
5 -->
6 <head>
7 <title>Test for parsing, storage, and serialization of CSS 'inherit' on all properties and 'unset' on inherited properties</title>
8 <script 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=375363">Mozilla Bug 375363</a>
14 <p id="display"></p>
15 <div id="content" style="display: none">
17 <div id="testnode"></div>
19 </div>
20 <pre id="test">
21 <script class="testbody" type="text/javascript">
23 /** Test for parsing, storage, and serialization of CSS 'inherit' on all
24 properties and 'unset' on inherited properties **/
26 var gDeclaration = document.getElementById("testnode").style;
28 function test_property(property)
30 var info = gCSSProperties[property];
32 var keywords = ["inherit"];
33 if (info.inherited)
34 keywords.push("unset");
36 keywords.forEach(function(keyword) {
37 function check_initial(sproperty) {
38 var sinfo = gCSSProperties[sproperty];
39 var val = gDeclaration.getPropertyValue(sproperty);
40 is(val, "", "value of '" + sproperty + "' before we do anything");
41 is(val, gDeclaration[sinfo.domProp],
42 "consistency between decl.getPropertyValue('" + sproperty + "') and decl." + sinfo.domProp);
44 check_initial(property);
45 if ("subproperties" in info)
46 for (var idx in info.subproperties)
47 check_initial(info.subproperties[idx]);
49 gDeclaration.setProperty(property, keyword, "");
51 function check_set(sproperty) {
52 var sinfo = gCSSProperties[sproperty];
53 val = gDeclaration.getPropertyValue(sproperty);
54 is(val, keyword,
55 keyword + " reported back for property '" + sproperty + "'");
56 is(val, gDeclaration[sinfo.domProp],
57 "consistency between decl.getPropertyValue('" + sproperty +
58 "') and decl." + sinfo.domProp);
60 check_set(property);
61 if ("subproperties" in info)
62 for (var idx in info.subproperties)
63 check_set(info.subproperties[idx]);
65 // We don't care particularly about the whitespace or the placement of
66 // semicolons, but for simplicity we'll test the current behavior.
67 if ("alias_for" in info) {
68 is(gDeclaration.cssText, info.alias_for + ": " + keyword + ";",
69 "declaration should serialize to exactly what went in (for " + keyword + ")");
70 } else if (info.type == CSS_TYPE_LEGACY_SHORTHAND) {
71 // We can't assert anything more meaningful here, really.
72 is(property, "zoom", "Zoom is a bit special because it never " +
73 "serializes as-is, we always serialize the longhands, " +
74 "but it doesn't just map to a single property " +
75 "(and thus we can't use the 'alias_for' mechanism)");
76 } else {
77 is(gDeclaration.cssText, property + ": " + keyword + ";",
78 "declaration should serialize to exactly what went in (for " + keyword + ")");
81 gDeclaration.removeProperty(property);
83 function check_final(sproperty) {
84 var sinfo = gCSSProperties[sproperty];
85 var val = gDeclaration.getPropertyValue(sproperty);
86 is(val, "", "value of '" + sproperty + "' after removal of value");
87 is(val, gDeclaration[sinfo.domProp],
88 "consistency between decl.getPropertyValue('" + sproperty + "') and decl." + sinfo.domProp);
90 check_final(property);
91 if ("subproperties" in info)
92 for (var idx in info.subproperties)
93 check_final(info.subproperties[idx]);
95 // can all properties be removed from the style?
96 function test_remove_all_properties(propName, value) {
97 var i, p = [];
98 for (i = 0; i < gDeclaration.length; i++) p.push(gDeclaration[i]);
99 for (i = 0; i < p.length; i++) gDeclaration.removeProperty(p[i]);
100 var errstr = "when setting property " + propName + " to " + value;
101 is(gDeclaration.length, 0, "unremovable properties " + errstr);
102 is(gDeclaration.cssText, "", "non-empty serialization after removing all properties " + errstr);
105 // sanity check shorthands to make sure disabled props aren't exposed
106 if (info.type != CSS_TYPE_LONGHAND) {
107 gDeclaration.setProperty(property, keyword, "");
108 test_remove_all_properties(property, keyword);
109 gDeclaration.removeProperty(property);
114 for (var prop in gCSSProperties)
115 test_property(prop);
117 </script>
118 </pre>
119 </body>
120 </html>