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-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/css/css-logical/logicalprops-with-variables.html
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
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>