diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/css/css-logical/logicalprops-with-variables.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
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.html | 69 |
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> |