Skip to content

Truly independent web browser

Tests/LibWeb: Time a lane hover from the transition it must cancel

Tim Ledbetter06c67a8ccc0d
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/frame-in-flight.js b/Tests/LibWeb/Text/input/HTML/frame-in-flight/frame-in-flight.js
index 8e4e70272fd..6032b577e38 100644
--- a/Tests/LibWeb/Text/input/HTML/frame-in-flight/frame-in-flight.js
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/frame-in-flight.js
@@ -93,14 +93,15 @@ function srcdocLoaded(iframe) {
// an earlier frame, has come together from it, beside which the lane hovers. A pointer move a test injects before the
// lane follows the pointer reaches no lane, and nothing else hands it to the host. Rendering opportunities stay manual
// until `during` is done. `documents` are those whose lanes `during` needs: a same-process iframe's document is laid
-// out after the document around it, and its frame lands on its own.
-async function whileLaneHovers(during, documents = [document]) {
+// out after the document around it, and its frame lands on its own. `frameTime`, if given, replaces the current time as
+// the frame time of the rendering update.
+async function whileLaneHovers(during, documents = [document], frameTime = undefined) {
if (document.readyState !== "complete")
await new Promise(resolve => window.addEventListener("load", resolve, { once: true }));
internals.setManualRenderingOpportunities(true);
try {
await nextTask();
- let frameTime = performance.now();
+ frameTime ??= performance.now();
internals.injectRenderingOpportunity(frameTime);
do await nextTask();
while (
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-cancels-a-host-transition-that-would-have-ended-since.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-cancels-a-host-transition-that-would-have-ended-since.html
index 87bfaea12e1..d6979e95ed7 100644
--- a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-cancels-a-host-transition-that-would-have-ended-since.html
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-cancels-a-host-transition-that-would-have-ended-since.html
@@ -15,16 +15,17 @@
asyncTest(async done => {
if (document.readyState !== "complete")
await new Promise(resolve => window.addEventListener("load", resolve, { once: true }));
- await twoFrames();
+ await nextFrame();
+ const transitionStart = await animationFrame();
const events = [];
for (const type of ["transitionend", "transitioncancel"])
box.addEventListener(type, event => events.push(`${event.type} ${event.propertyName}`));
- // The rendering update that the lane follows starts the short transition.
+ // The rendering update of this animation frame starts the short transition.
box.classList.add("green");
await whileLaneHovers(frameTime => {
internals.injectHoverPointer(50, 50, frameTime + 1, 1);
while (performance.now() < frameTime + 50) { }
- });
+ }, [document], transitionStart + 1);
await twoFrames();
println(`transition events: ${events.join(", ")}`);
println(`#box matches :hover: ${box.matches(":hover")}`);