Skip to content

Truly independent web browser

LibWeb: Import optional property initial-value test

Andreas Klingdeb18abec4cb
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-properties-values-api/at-property-optional-initial-value.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-properties-values-api/at-property-optional-initial-value.txt
new file mode 100644
index 00000000000..f318cee8101
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-properties-values-api/at-property-optional-initial-value.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Fail
+Fail @property with empty initial-value should use space character
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-properties-values-api/at-property-optional-initial-value.html b/Tests/LibWeb/Text/input/wpt-import/css/css-properties-values-api/at-property-optional-initial-value.html
new file mode 100644
index 00000000000..b46745b3976
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-properties-values-api/at-property-optional-initial-value.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Properties and Values API: optional initial-value descriptor</title>
+<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#initial-value-descriptor">
+<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/9078">
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<style>
+@property --registered {
+ syntax: '*';
+ initial-value: ;
+ inherits: false;
+}
+#target {
+ --test-bg: var(--registered) green;
+ --test-fallback: var(--registered, red);
+ background-color: var(--test-bg, var(--test-fallback));
+}
+</style>
+<div id="target"></div>
+<script>
+test(function() {
+ const target = document.getElementById('target');
+ const style = getComputedStyle(target);
+
+ // When initial-value is omitted (empty space), the property should be registered
+ // with a space character as the initial value, making var(--registered) green
+ // evaluate to " green" which is a valid color value.
+ assert_equals(style.backgroundColor, 'rgb(0, 128, 0)',
+ 'background-color should be green when @property has empty initial-value');
+ }, '@property with empty initial-value should use space character');
+</script>