summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-logical/logicalprops-with-variables.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/css/css-logical/logicalprops-with-variables.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-logical/logicalprops-with-variables.html')
-rw-r--r--testing/web-platform/tests/css/css-logical/logicalprops-with-variables.html69
1 files changed, 69 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-logical/logicalprops-with-variables.html b/testing/web-platform/tests/css/css-logical/logicalprops-with-variables.html
new file mode 100644
index 0000000000..fc52495bc0
--- /dev/null
+++ b/testing/web-platform/tests/css/css-logical/logicalprops-with-variables.html
@@ -0,0 +1,69 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Logical properties with <code>var()</code></title>
+<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com" />
+<link rel="help" href="https://drafts.csswg.org/css-logical-1/#box">
+<link rel="help" href="https://drafts.csswg.org/css-variables-1/">
+<meta name="assert" content="Checks that logical properties can use the 'var()' notation to reference custom properties.">
+<div id="target"></div>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+const target = document.getElementById("target");
+const {style} = target;
+const computedStyle = getComputedStyle(target);
+let title;
+
+function check(property, specifiedExpected, expectedComputed) {
+ test(() => {
+ const specifiedActual = style.getPropertyValue(property);
+ assert_equals(specifiedActual, specifiedExpected, "Specified value");
+ const computedActual = computedStyle.getPropertyValue(property);
+ assert_equals(computedActual, expectedComputed, "Computed value");
+ }, title + " - " + property);
+}
+
+{
+ title = "Logical longhands with variables";
+ style.cssText = "";
+ style.setProperty("--one", "1px");
+ style.setProperty("--two", "2px");
+ style.setProperty("margin-inline-start", "var(--one)");
+ style.setProperty("margin-inline-end", "var(--two)");
+
+ check("margin-inline-start", "var(--one)", "1px");
+ check("margin-inline-end", "var(--two)", "2px");
+ check("margin-inline", "", "1px 2px");
+}
+{
+ title = "Logical shorthand with 1 variable";
+ style.cssText = "";
+ style.setProperty("--one", "1px");
+ style.setProperty("margin-inline", "var(--one)");
+
+ check("margin-inline-start", "", "1px");
+ check("margin-inline-end", "", "1px");
+ check("margin-inline", "var(--one)", "1px");
+}
+{
+ title = "Logical shorthand with 2 variables";
+ style.cssText = "";
+ style.setProperty("--one", "1px");
+ style.setProperty("--two", "2px");
+ style.setProperty("margin-inline", "var(--one) var(--two)");
+
+ check("margin-inline-start", "", "1px");
+ check("margin-inline-end", "", "2px");
+ check("margin-inline", "var(--one) var(--two)", "1px 2px");
+}
+{
+ title = "Logical shorthand with 1 variable and 1 length";
+ style.cssText = "";
+ style.setProperty("--one", "1px");
+ style.setProperty("margin-inline", "var(--one) 2px");
+
+ check("margin-inline-start", "", "1px");
+ check("margin-inline-end", "", "2px");
+ check("margin-inline", "var(--one) 2px", "1px 2px");
+}
+</script>