mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 02:05:07 +02:00
Tests: Import WPT CSSOM tests about serialization
This is an area we're lacking in, so let's bring these in-tree to track them more easily. :^)
This commit is contained in:
committed by
Andreas Kling
parent
12442ca430
commit
2fc164c0b6
Notes:
github-actions[bot]
2024-11-30 10:03:37 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/2fc164c0b64 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2638
@@ -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>
|
||||
Reference in New Issue
Block a user