diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/css/cssom/serialize-custom-props.html | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.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/cssom/serialize-custom-props.html')
-rw-r--r-- | testing/web-platform/tests/css/cssom/serialize-custom-props.html | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/cssom/serialize-custom-props.html b/testing/web-platform/tests/css/cssom/serialize-custom-props.html new file mode 100644 index 0000000000..cfe96ff0aa --- /dev/null +++ b/testing/web-platform/tests/css/cssom/serialize-custom-props.html @@ -0,0 +1,69 @@ +<link rel=author title="Tab Atkins-Bittner" href="https://www.xanthir.com/contact/"> +<link rel="help" href="https://drafts.csswg.org/css-values/#calc-range"> +<body><!doctype html> +<title>Serializing Integers Never Uses Scinot</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<link rel=author title="Tab Atkins-Bittner" href="https://www.xanthir.com/contact/"> +<link rel="help" href="https://drafts.csswg.org/cssom/#serialize-a-css-component-value"> +<!-- + Per CSSOM, integers always serialize all their digits out. + They never serialize to scinot, regardless of size, + because that makes them stop being an integer. + This applies to custom properties as well. +--> +<body> + +<script> + +try { +CSS.registerProperty({ + name: "--two", + value: "<integer>", + inherits: true, + initial: -1 +}); +}catch(e){} + +testIntLength(4); +testIntLength(6); +testIntLength(8); +testIntLength(12); +// JS starts serializing with scinot at 22 digits... +testIntLength(25); + +function testIntLength(len) { + let el = document.body; + const val = "1".repeat(len); + test(()=>{ + el.removeAttribute("style"); + const nullVal = getComputedStyle(el).zIndex; + el.style.zIndex=val; + assert_not_equals(getComputedStyle(el).zIndex, nullVal) + }, `z-index can take a ${len}-digit integer`); + + test(()=>{ + el.removeAttribute("style"); + el.style.setProperty("--one", val); + assert_equals(getComputedStyle(el).getPropertyValue("--one"), val); + }, `An unregistered custom prop can take a ${len}-digit integer`); + + test(()=>{ + el.removeAttribute("style"); + el.style.setProperty("--two", val); + assert_equals(getComputedStyle(el).getPropertyValue("--two"), val); + }, `An <integer> custom prop can take a ${len}-digit integer`); + + test(()=>{ + el.removeAttribute("style"); + el.style.zIndex = val; + const standardVal = getComputedStyle(el).zIndex; + el.removeAttribute("style"); + el.style.setProperty("--three", val); + el.style.zIndex = "var(--three)"; + assert_equals(getComputedStyle(el).zIndex, standardVal); + }, `z-index can take a custom property set to a ${len}-digit integer`); +} + +</script> |