Skip to content

Truly independent web browser

LibWeb: Test monospace below an animation at its ancestor's size

Andreas Kling1d17bc9cca06
diff --git a/Tests/LibWeb/Text/expected/css/monospace-follows-animated-ancestor-font-past-its-delay.txt b/Tests/LibWeb/Text/expected/css/monospace-follows-animated-ancestor-font-past-its-delay.txt
new file mode 100644
index 00000000000..46917108964
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/monospace-follows-animated-ancestor-font-past-its-delay.txt
@@ -0,0 +1,7 @@
+no animation: 16px, monospace 13px, ::before 13px, added 13px
+in its delay, at the ancestor's size: 16px, monospace 13px, ::before 13px, added 13px
+past its delay, at the ancestor's size: 16px, monospace 13px, ::before 13px, added 13px
+canceled: 16px, monospace 13px, ::before 13px, added 13px
+in its delay, at another size: 16px, monospace 13px, ::before 13px, added 13px
+past its delay, at another size: 20px, monospace 20px, ::before 20px, added 20px
+canceled: 16px, monospace 13px, ::before 13px, added 13px
diff --git a/Tests/LibWeb/Text/input/css/monospace-follows-animated-ancestor-font-past-its-delay.html b/Tests/LibWeb/Text/input/css/monospace-follows-animated-ancestor-font-past-its-delay.html
new file mode 100644
index 00000000000..d768711d6ae
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/monospace-follows-animated-ancestor-font-past-its-delay.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<style>
+ .monospace {
+ font-family: monospace;
+ }
+ #reader::before {
+ content: "before";
+ }
+</style>
+<div id="ancestor">
+ <div class="monospace" id="reader"></div>
+</div>
+<script src="../include.js"></script>
+<script>
+ function dump(label) {
+ const added = document.createElement("div");
+ added.className = "monospace";
+ ancestor.append(added);
+ const size = (element, pseudo) => getComputedStyle(element, pseudo).fontSize;
+ println(`${label}: ${size(ancestor)}, monospace ${size(reader)}, ::before ${size(reader, "::before")}, added ${size(added)}`);
+ added.remove();
+ }
+
+ test(() => {
+ dump("no animation");
+
+ const atItsOwnSize = ancestor.animate([{ fontSize: "16px" }, { fontSize: "16px" }], { duration: 1000, delay: 1000 });
+ atItsOwnSize.pause();
+ atItsOwnSize.currentTime = 0;
+ dump("in its delay, at the ancestor's size");
+ atItsOwnSize.currentTime = 1500;
+ dump("past its delay, at the ancestor's size");
+ atItsOwnSize.cancel();
+ dump("canceled");
+
+ const atAnotherSize = ancestor.animate([{ fontSize: "20px" }, { fontSize: "20px" }], { duration: 1000, delay: 1000 });
+ atAnotherSize.pause();
+ atAnotherSize.currentTime = 0;
+ dump("in its delay, at another size");
+ atAnotherSize.currentTime = 1500;
+ dump("past its delay, at another size");
+ atAnotherSize.cancel();
+ dump("canceled");
+ });
+</script>