Truly independent web browser
LibWeb: Test root-relative lengths under an animated root font
Andreas Kling75612673297b
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/clock-tick-leaves-a-moving-root-font-to-the-host.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/clock-tick-leaves-a-moving-root-font-to-the-host.txtnew file mode 100644index 00000000000..547c06ffc7a--- /dev/null+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/clock-tick-leaves-a-moving-root-font-to-the-host.txt@@ -0,0 +1,2 @@+last frame presented by: commit+a tick presented the box: falsediff --git a/Tests/LibWeb/Text/expected/css/rem-follows-animated-root-font.txt b/Tests/LibWeb/Text/expected/css/rem-follows-animated-root-font.txtnew file mode 100644index 00000000000..f344974cd48--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/rem-follows-animated-root-font.txt@@ -0,0 +1,64 @@+no animation:+ root font: 20px/25px+ em, rem on the root itself: 20px, 20px+ rem, rlh: 200px, 25px, laid out 200+ rem, rlh on ::before: 40px, 50px+ em below the root: 60px+ rem, em below a fixed font: 100px, 20px+running animation:+ root font: 30px/40px+ em, rem on the root itself: 20px, 20px+ rem, rlh: 200px, 25px, laid out 200+ rem, rlh on ::before: 40px, 50px+ em below the root: 90px+ rem, em below a fixed font: 100px, 20px+ rem on an element added meanwhile: 20px+canceled animation:+ root font: 20px/25px+ em, rem on the root itself: 20px, 20px+ rem, rlh: 200px, 25px, laid out 200+ rem, rlh on ::before: 40px, 50px+ em below the root: 60px+ rem, em below a fixed font: 100px, 20px+script animation halfway:+ root font: 20px/25px+ em, rem on the root itself: 20px, 20px+ rem, rlh: 200px, 25px, laid out 200+ rem, rlh on ::before: 40px, 50px+ em below the root: 60px+ rem, em below a fixed font: 100px, 20px+script animation further:+ root font: 25px/25px+ em, rem on the root itself: 20px, 20px+ rem, rlh: 200px, 25px, laid out 200+ rem, rlh on ::before: 40px, 50px+ em below the root: 75px+ rem, em below a fixed font: 100px, 20px+script animation canceled:+ root font: 20px/25px+ em, rem on the root itself: 20px, 20px+ rem, rlh: 200px, 25px, laid out 200+ rem, rlh on ::before: 40px, 50px+ em below the root: 60px+ rem, em below a fixed font: 100px, 20px+transition at its start:+ root font: 20px/25px+ em, rem on the root itself: 40px, 40px+ rem, rlh: 200px, 25px, laid out 200+ rem, rlh on ::before: 40px, 50px+ em below the root: 60px+ rem, em below a fixed font: 100px, 20px+transition halfway:+ root font: 30px/40px+ em, rem on the root itself: 40px, 40px+ rem, rlh: 400px, 55px, laid out 400+ rem, rlh on ::before: 80px, 110px+ em below the root: 90px+ rem, em below a fixed font: 100px, 20px+transition finished:+ root font: 40px/55px+ em, rem on the root itself: 40px, 40px+ rem, rlh: 400px, 55px, laid out 400+ rem, rlh on ::before: 80px, 110px+ em below the root: 120px+ rem, em below a fixed font: 100px, 20pxdiff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/clock-tick-leaves-a-moving-root-font-to-the-host.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/clock-tick-leaves-a-moving-root-font-to-the-host.htmlnew file mode 100644index 00000000000..b89b43991f9--- /dev/null+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/clock-tick-leaves-a-moving-root-font-to-the-host.html@@ -0,0 +1,38 @@+<!DOCTYPE html>+<script src="../../include.js"></script>+<script src="frame-in-flight.js"></script>+<style>+ @keyframes root-font {+ from { font-size: 10px; }+ to { font-size: 30px; }+ }+ html.animated {+ animation: root-font 10s linear infinite alternate;+ }+ #reader {+ width: 10rem;+ height: 10px;+ }+</style>+<div id="reader"></div>+<script>+ // A box resolves `rem` against the root element's font as the main thread styles it, which a clock tick does not+ // restyle. The ticks leave the animations of the root element to the main thread.+ asyncTest(async done => {+ const result = await whileLaneAnimates(() => {+ document.documentElement.classList.add("animated");+ return document.documentElement.getAnimations()[0];+ }, (frameTime, animation) => {+ internals.injectClockTick(frameTime + 3000);+ return {+ presented: internals.presentedBorderBox(reader),+ presentedBy: internals.lastFramePresentedBy(document),+ animation,+ };+ });+ result.animation.cancel();+ println(`last frame presented by: ${result.presentedBy}`);+ println(`a tick presented the box: ${result.presented !== null}`);+ done();+ });+</script>diff --git a/Tests/LibWeb/Text/input/css/rem-follows-animated-root-font.html b/Tests/LibWeb/Text/input/css/rem-follows-animated-root-font.htmlnew file mode 100644index 00000000000..df0b51f3e3f--- /dev/null+++ b/Tests/LibWeb/Text/input/css/rem-follows-animated-root-font.html@@ -0,0 +1,101 @@+<!DOCTYPE html>+<style>+ @keyframes root-font {+ from, to { font-size: 30px; line-height: 40px; }+ }+ html {+ font-size: 20px;+ line-height: 25px;+ padding-left: 1em;+ padding-right: 1rem;+ }+ html.animated {+ animation: root-font 1000s linear;+ }+ html.transitioning {+ transition: font-size 1000s linear, line-height 1000s linear;+ }+ html.moved {+ font-size: 40px;+ line-height: 55px;+ }+ #reader {+ width: 10rem;+ height: 1rlh;+ }+ #reader::before {+ content: "";+ margin-left: 2rem;+ margin-right: 2rlh;+ }+ #em {+ width: 3em;+ }+ #fixed {+ font-size: 10px;+ line-height: 10px;+ }+ #below-fixed {+ width: 5rem;+ height: 2em;+ }+</style>+<div id="reader"></div>+<div id="em"></div>+<div id="fixed"><div id="below-fixed"></div></div>+<script src="../include.js"></script>+<script>+ function dump(label) {+ const root = getComputedStyle(document.documentElement);+ const readerStyle = getComputedStyle(reader);+ const before = getComputedStyle(reader, "::before");+ const belowFixedStyle = getComputedStyle(document.getElementById("below-fixed"));+ println(`${label}:`);+ println(` root font: ${root.fontSize}/${root.lineHeight}`);+ // FIXME: A length on the element whose font animates resolves against the font of its record, the root's or+ // any other's, not against the font the animation gives it.+ println(` em, rem on the root itself: ${root.paddingLeft}, ${root.paddingRight}`);+ println(` rem, rlh: ${readerStyle.width}, ${readerStyle.height}, laid out ${reader.getBoundingClientRect().width}`);+ println(` rem, rlh on ::before: ${before.marginLeft}, ${before.marginRight}`);+ println(` em below the root: ${getComputedStyle(em).width}`);+ println(` rem, em below a fixed font: ${belowFixedStyle.width}, ${belowFixedStyle.height}`);+ }++ test(() => {+ const root = document.documentElement;+ dump("no animation");++ root.classList.add("animated");+ dump("running animation");+ const added = document.createElement("div");+ added.style.width = "1rem";+ document.body.append(added);+ println(` rem on an element added meanwhile: ${getComputedStyle(added).width}`);+ added.remove();+ root.getAnimations()[0].cancel();+ dump("canceled animation");+ root.classList.remove("animated");++ const scripted = root.animate([{ fontSize: "10px" }, { fontSize: "30px" }], 1000);+ scripted.pause();+ scripted.currentTime = 500;+ dump("script animation halfway");+ scripted.currentTime = 750;+ dump("script animation further");+ scripted.cancel();+ dump("script animation canceled");++ root.classList.add("transitioning");+ getComputedStyle(root).fontSize;+ root.classList.add("moved");+ dump("transition at its start");+ for (const transition of root.getAnimations()) {+ transition.pause();+ transition.currentTime = 500000;+ }+ dump("transition halfway");+ for (const transition of root.getAnimations())+ transition.finish();+ dump("transition finished");+ });+</script>