Truly independent web browser
Tests/LibWeb: Test a key scroll after a key with nothing to scroll
Andreas Klinge5b442d3944c
diff --git a/Tests/LibWeb/Text/expected/async-scrolling/key-scrolls-beside-a-busy-task-after-a-key-with-nothing-to-scroll.txt b/Tests/LibWeb/Text/expected/async-scrolling/key-scrolls-beside-a-busy-task-after-a-key-with-nothing-to-scroll.txtnew file mode 100644index 00000000000..4cecbb1d1bc--- /dev/null+++ b/Tests/LibWeb/Text/expected/async-scrolling/key-scrolls-beside-a-busy-task-after-a-key-with-nothing-to-scroll.txt@@ -0,0 +1,3 @@+beside the task: compositor offset=0+keys the page heard of: ArrowUp, ArrowDown+main thread offset: 0diff --git a/Tests/LibWeb/Text/input/async-scrolling/key-scrolls-beside-a-busy-task-after-a-key-with-nothing-to-scroll.html b/Tests/LibWeb/Text/input/async-scrolling/key-scrolls-beside-a-busy-task-after-a-key-with-nothing-to-scroll.htmlnew file mode 100644index 00000000000..851ff06a012--- /dev/null+++ b/Tests/LibWeb/Text/input/async-scrolling/key-scrolls-beside-a-busy-task-after-a-key-with-nothing-to-scroll.html@@ -0,0 +1,39 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<style>+ body {+ margin: 0;+ height: 5000px;+ }+</style>+<script>+ // A key at the end of the scroll range has nothing to do, so it holds nothing back while a task keeps the main+ // thread busy. The key after it still scrolls, and the page still hears of both.+ promiseTest(async () => {+ const compositorOffset = () => internals.compositorScrollState().scrollOffset.y;+ const keys = [];+ document.addEventListener("keyup", event => keys.push(event.key));+ await animationFrame();+ await animationFrame();+ internals.synchronizeCompositor();++ internals.sendKeyThroughUIProcess("Up");+ internals.sendKeyThroughUIProcess("Down");++ // NB: This only gives up on a scroll that never comes, so the time limit can't fail a slow machine's run of a fixed+ // engine.+ const giveUpAt = performance.now() + 5000;+ while (compositorOffset() !== 100 && performance.now() < giveUpAt) {+ // Stay in this task.+ }+ println(`beside the task: compositor offset=${compositorOffset()}`);++ // NB: These only give up on what never comes as well.+ let until = performance.now() + 4000;+ while (keys.length < 2 && performance.now() < until) await animationFrame();+ println(`keys the page heard of: ${keys.join(", ")}`);+ until = performance.now() + 4000;+ while (window.scrollY !== 100 && performance.now() < until) await animationFrame();+ println(`main thread offset: ${window.scrollY}`);+ });+</script>