Skip to content

Truly independent web browser

LibWeb: Test a chain of animated custom properties in a layout update

Andreas Kling13f0540a650f
diff --git a/Tests/LibWeb/Text/expected/css/custom-property-animations-chain-in-a-layout-update.txt b/Tests/LibWeb/Text/expected/css/custom-property-animations-chain-in-a-layout-update.txt
new file mode 100644
index 00000000000..1c314d04527
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/custom-property-animations-chain-in-a-layout-update.txt
@@ -0,0 +1 @@
+laid out at: 170px
diff --git a/Tests/LibWeb/Text/input/css/custom-property-animations-chain-in-a-layout-update.html b/Tests/LibWeb/Text/input/css/custom-property-animations-chain-in-a-layout-update.html
new file mode 100644
index 00000000000..0a2b114d857
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/custom-property-animations-chain-in-a-layout-update.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<body>
+<script src="../include.js"></script>
+<div id="target"></div>
+<script>
+ test(() => {
+ // Each value of the chain moves in the style pass after the one it reads, and a style update in the layout update
+ // runs a limited number of passes, so settling the chain takes many more rounds than the document has elements.
+ const depth = 170;
+ const style = document.createElement("style");
+ const animations = [];
+ for (let level = 1; level <= depth; ++level) {
+ CSS.registerProperty({ name: `--level${level}`, syntax: "<length>", inherits: true, initialValue: "0px" });
+ const previous = level === 1 ? "0px" : `var(--level${level - 1})`;
+ const value = `--level${level}: calc(${previous} + 1px)`;
+ style.textContent += `@keyframes level${level} { from { ${value} } to { ${value} } }\n`;
+ animations.push(`level${level} 1000s linear both`);
+ }
+ document.head.append(style);
+ target.style.animation = animations.join(", ");
+ target.style.width = `var(--level${depth})`;
+ println(`laid out at: ${target.getBoundingClientRect().width}px`);
+ });
+</script>