Files
ladybird/Tests/LibWeb/Text/input/selection-auto-scroll.html
Jelle Raaijmakers fead8b92f9 LibWeb: Use correct scrollability check for autoscrolling
We only checked if the paintable box had scrollable overflow, but that
was too simple - we now use the same logic that checks whether a box can
be scrolled by a mousewheel event.

The autoscrolling test was updated as well to use rAF+rAF+timeout
instead of a fixed 1000ms timeout, which is prone to flakiness.
2026-03-24 13:55:37 +01:00

53 lines
1.4 KiB
HTML

<!DOCTYPE html>
<style>
div {
overflow: auto;
width: 200px;
height: 100px;
font-size: 16px;
}
</style>
<div id="vertical">line1<br>line2<br>line3<br>line4<br>line5<br>line6<br>line7<br>line8<br>line9<br>line10</div>
<div id="hidden" style="overflow: hidden">line1<br>line2<br>line3<br>line4<br>line5<br>line6<br>line7<br>line8<br>line9<br>line10</div>
<script src="include.js"></script>
<script>
function afterAutoScrollTick() {
return new Promise(resolve => {
requestAnimationFrame(() => {
requestAnimationFrame(() => {
setTimeout(resolve, 0);
});
});
});
}
asyncTest(async (done) => {
document.body.offsetWidth; // force layout
println(`before: ${vertical.scrollTop}`);
let rect = vertical.getBoundingClientRect();
internals.mouseDown(rect.x + 10, rect.y + 10);
internals.mouseMove(rect.x + 10, rect.y + rect.height + 50);
await afterAutoScrollTick();
println(`after: ${vertical.scrollTop}`);
internals.mouseUp(rect.x + 10, rect.y + rect.height + 50);
println(`hidden before: ${hidden.scrollTop}`);
rect = hidden.getBoundingClientRect();
internals.mouseDown(rect.x + 10, rect.y + 10);
internals.mouseMove(rect.x + 10, rect.y + rect.height + 50);
await afterAutoScrollTick();
println(`hidden after: ${hidden.scrollTop}`);
internals.mouseUp(rect.x + 10, rect.y + rect.height + 50);
done();
});
</script>