summaryrefslogtreecommitdiffstats
path: root/layout/style/test/test_property_database.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
commit9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /layout/style/test/test_property_database.html
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.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_property_database.html')
-rw-r--r--layout/style/test/test_property_database.html173
1 files changed, 173 insertions, 0 deletions
diff --git a/layout/style/test/test_property_database.html b/layout/style/test/test_property_database.html
new file mode 100644
index 0000000000..ba04ec341a
--- /dev/null
+++ b/layout/style/test/test_property_database.html
@@ -0,0 +1,173 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+-->
+<head>
+ <title>Test that property_database.js contains all supported CSS properties</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="text/javascript" src="css_properties.js"></script>
+ <script type="text/javascript" src="property_database.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<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 that property_database.js contains all supported CSS properties **/
+
+/*
+ * Here we are testing the hand-written property_database.js against
+ * the autogenerated css_properties.js to make sure that everything in
+ * css_properties.js is in property_database.js.
+ *
+ * This prevents CSS properties from being added to the code without
+ * also being put under the minimal test coverage provided by the tests
+ * that use property_database.js.
+ */
+
+for (var idx in gLonghandProperties) {
+ var prop = gLonghandProperties[idx];
+ if (prop.pref && !IsCSSPropertyPrefEnabled(prop.pref)) {
+ continue;
+ }
+ var present = prop.name in gCSSProperties;
+ ok(present,
+ "'" + prop.name + "' listed in gCSSProperties");
+ if (present) {
+ is(gCSSProperties[prop.name].type, CSS_TYPE_LONGHAND,
+ "'" + prop.name + "' listed as CSS_TYPE_LONGHAND");
+ is(gCSSProperties[prop.name].domProp, prop.prop,
+ "'" + prop.name + "' listed with correct DOM property name");
+ }
+}
+for (var idx in gShorthandProperties) {
+ var prop = gShorthandProperties[idx];
+ if (prop.pref && !IsCSSPropertyPrefEnabled(prop.pref)) {
+ continue;
+ }
+ if (prop.name == "all") {
+ // "all" isn't listed in property_database.js.
+ continue;
+ }
+ var present = prop.name in gCSSProperties;
+ ok(present,
+ "'" + prop.name + "' listed in gCSSProperties");
+ if (present) {
+ ok(gCSSProperties[prop.name].type == CSS_TYPE_TRUE_SHORTHAND ||
+ gCSSProperties[prop.name].type == CSS_TYPE_LEGACY_SHORTHAND ||
+ gCSSProperties[prop.name].type == CSS_TYPE_SHORTHAND_AND_LONGHAND,
+ "'" + prop.name + "' listed as CSS_TYPE_TRUE_SHORTHAND, CSS_TYPE_LEGACY_SHORTHAND, or CSS_TYPE_SHORTHAND_AND_LONGHAND");
+ ok(gCSSProperties[prop.name].domProp == prop.prop,
+ "'" + prop.name + "' listed with correct DOM property name");
+ }
+}
+for (var idx in gShorthandPropertiesLikeLonghand) {
+ var prop = gShorthandPropertiesLikeLonghand[idx];
+ if (prop.pref && !IsCSSPropertyPrefEnabled(prop.pref)) {
+ continue;
+ }
+ var present = prop.name in gCSSProperties;
+ ok(present,
+ "'" + prop.name + "' listed in gCSSProperties");
+ if (present) {
+ ok(gCSSProperties[prop.name].type == CSS_TYPE_SHORTHAND_AND_LONGHAND,
+ "'" + prop.name + "' listed as CSS_TYPE_SHORTHAND_AND_LONGHAND");
+ ok(gCSSProperties[prop.name].domProp == prop.prop,
+ "'" + prop.name + "' listed with correct DOM property name");
+ }
+}
+
+/*
+ * Test that all shorthand properties have a subproperty list and all
+ * longhand properties do not.
+ */
+for (var prop in gCSSProperties) {
+ var entry = gCSSProperties[prop];
+ if (entry.pref && !IsCSSPropertyPrefEnabled(entry.pref)) {
+ continue;
+ }
+ if (entry.type == CSS_TYPE_LONGHAND) {
+ ok(!("subproperties" in entry),
+ "longhand property '" + prop + "' must not have subproperty list");
+ } else if (entry.type == CSS_TYPE_TRUE_SHORTHAND ||
+ entry.type == CSS_TYPE_SHORTHAND_AND_LONGHAND) {
+ ok("subproperties" in entry,
+ "shorthand property '" + prop + "' must have subproperty list");
+ }
+
+ if ("subproperties" in entry) {
+ var good = true;
+ if (entry.subproperties.length < 1) {
+ info("subproperty list for '" + prop + "' is empty");
+ good = false;
+ }
+ for (var idx in entry.subproperties) {
+ var subprop = entry.subproperties[idx];
+ if (!(subprop in gCSSProperties)) {
+ info("subproperty list for '" + prop + "' lists nonexistent subproperty '" + subprop + "'");
+ good = false;
+ }
+ }
+ ok(good, "property '" + prop + "' has a good subproperty list");
+ }
+
+ ok("initial_values" in entry && entry.initial_values.length >= 1,
+ "must have initial values for property '" + prop + "'");
+ ok("other_values" in entry && entry.other_values.length >= 1,
+ "must have non-initial values for property '" + prop + "'");
+}
+
+/*
+ * Test that only longhand properties or its aliases are listed as logical
+ * properties.
+ */
+for (var prop in gCSSProperties) {
+ var entry = gCSSProperties[prop];
+ if (entry.logical) {
+ ok(entry.type == CSS_TYPE_LONGHAND ||
+ (entry.alias_for && gCSSProperties[entry.alias_for].logical),
+ "property '" + prop + "' is listed as CSS_TYPE_LONGHAND or is an alias due to it " +
+ "being a logical property");
+ }
+}
+
+/*
+ * Test that axis is only specified for logical properties.
+ */
+for (var prop in gCSSProperties) {
+ var entry = gCSSProperties[prop];
+ if (entry.axis) {
+ ok(entry.logical,
+ "property '" + prop + "' is listed as an logical property due to its " +
+ "being listed as an axis-related property");
+ }
+}
+
+/*
+ * Test that DOM properties match the expected rules.
+ */
+for (var prop in gCSSProperties) {
+ var entry = gCSSProperties[prop];
+ var expectedDOMProp = prop.replace(/-([a-z])/g,
+ function(m, p1, offset, str) {
+ return p1.toUpperCase();
+ });
+ if (expectedDOMProp == "float") {
+ expectedDOMProp = "cssFloat";
+ } else if (prop.startsWith("-webkit")) {
+ // Our DOM accessors for webkit-prefixed properties start with lowercase w,
+ // not uppercase like standard DOM accessors.
+ expectedDOMProp = expectedDOMProp.replace(/^W/, "w");
+ }
+ is(entry.domProp, expectedDOMProp, "DOM property for " + prop);
+}
+</script>
+</pre>
+</body>
+</html>