summaryrefslogtreecommitdiffstats
path: root/layout/style/test/test_inherit_storage.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /layout/style/test/test_inherit_storage.html
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'layout/style/test/test_inherit_storage.html')
-rw-r--r--layout/style/test/test_inherit_storage.html120
1 files changed, 120 insertions, 0 deletions
diff --git a/layout/style/test/test_inherit_storage.html b/layout/style/test/test_inherit_storage.html
new file mode 100644
index 0000000000..a9587d34d9
--- /dev/null
+++ b/layout/style/test/test_inherit_storage.html
@@ -0,0 +1,120 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=375363
+-->
+<head>
+ <title>Test for parsing, storage, and serialization of CSS 'inherit' on all properties and 'unset' on inherited properties</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="text/javascript" src="property_database.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=375363">Mozilla Bug 375363</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+<div id="testnode"></div>
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for parsing, storage, and serialization of CSS 'inherit' on all
+ properties and 'unset' on inherited properties **/
+
+var gDeclaration = document.getElementById("testnode").style;
+
+function test_property(property)
+{
+ var info = gCSSProperties[property];
+
+ var keywords = ["inherit"];
+ if (info.inherited)
+ keywords.push("unset");
+
+ keywords.forEach(function(keyword) {
+ function check_initial(sproperty) {
+ var sinfo = gCSSProperties[sproperty];
+ var val = gDeclaration.getPropertyValue(sproperty);
+ is(val, "", "value of '" + sproperty + "' before we do anything");
+ is(val, gDeclaration[sinfo.domProp],
+ "consistency between decl.getPropertyValue('" + sproperty + "') and decl." + sinfo.domProp);
+ }
+ check_initial(property);
+ if ("subproperties" in info)
+ for (var idx in info.subproperties)
+ check_initial(info.subproperties[idx]);
+
+ gDeclaration.setProperty(property, keyword, "");
+
+ function check_set(sproperty) {
+ var sinfo = gCSSProperties[sproperty];
+ val = gDeclaration.getPropertyValue(sproperty);
+ is(val, keyword,
+ keyword + " reported back for property '" + sproperty + "'");
+ is(val, gDeclaration[sinfo.domProp],
+ "consistency between decl.getPropertyValue('" + sproperty +
+ "') and decl." + sinfo.domProp);
+ }
+ check_set(property);
+ if ("subproperties" in info)
+ for (var idx in info.subproperties)
+ check_set(info.subproperties[idx]);
+
+ // We don't care particularly about the whitespace or the placement of
+ // semicolons, but for simplicity we'll test the current behavior.
+ if ("alias_for" in info) {
+ is(gDeclaration.cssText, info.alias_for + ": " + keyword + ";",
+ "declaration should serialize to exactly what went in (for " + keyword + ")");
+ } else if (info.type == CSS_TYPE_LEGACY_SHORTHAND) {
+ // We can't assert anything more meaningful here, really.
+ is(property, "zoom", "Zoom is a bit special because it never " +
+ "serializes as-is, we always serialize the longhands, " +
+ "but it doesn't just map to a single property " +
+ "(and thus we can't use the 'alias_for' mechanism)");
+ } else {
+ is(gDeclaration.cssText, property + ": " + keyword + ";",
+ "declaration should serialize to exactly what went in (for " + keyword + ")");
+ }
+
+ gDeclaration.removeProperty(property);
+
+ function check_final(sproperty) {
+ var sinfo = gCSSProperties[sproperty];
+ var val = gDeclaration.getPropertyValue(sproperty);
+ is(val, "", "value of '" + sproperty + "' after removal of value");
+ is(val, gDeclaration[sinfo.domProp],
+ "consistency between decl.getPropertyValue('" + sproperty + "') and decl." + sinfo.domProp);
+ }
+ check_final(property);
+ if ("subproperties" in info)
+ for (var idx in info.subproperties)
+ check_final(info.subproperties[idx]);
+
+ // can all properties be removed from the style?
+ function test_remove_all_properties(propName, value) {
+ var i, p = [];
+ for (i = 0; i < gDeclaration.length; i++) p.push(gDeclaration[i]);
+ for (i = 0; i < p.length; i++) gDeclaration.removeProperty(p[i]);
+ var errstr = "when setting property " + propName + " to " + value;
+ is(gDeclaration.length, 0, "unremovable properties " + errstr);
+ is(gDeclaration.cssText, "", "non-empty serialization after removing all properties " + errstr);
+ }
+
+ // sanity check shorthands to make sure disabled props aren't exposed
+ if (info.type != CSS_TYPE_LONGHAND) {
+ gDeclaration.setProperty(property, keyword, "");
+ test_remove_all_properties(property, keyword);
+ gDeclaration.removeProperty(property);
+ }
+ });
+}
+
+for (var prop in gCSSProperties)
+ test_property(prop);
+
+</script>
+</pre>
+</body>
+</html>