<!DOCTYPE HTML>
<script src='../../resources/testharness.js'></script>
<script src='../../resources/testharnessreport.js'></script>
<script src='../../resources/gesture-util.js'></script>
<style>
body,html {
margin: 0;
width: 10000px;
height: 10000px;
}
</style>
<script>
const scroller = document.scrollingElement;
let floatPrecision = 0.00001;
window.addEventListener('load', async () => {
await waitForCompositorCommit();
promise_test(async () => {
scroller.scrollTop = 0;
scroller.scrollLeft = 0;
const distance = 5;
const x = 400;
const y = 300;
const precise_deltas = true;
if (window.internals) {
window.internals.setPageScaleFactor(4);
window.internals.setVisualViewportOffset(600, 450);
await waitForCompositorCommit();
}
// We always truncate the scroll offset.
let expected_scroll = Math.floor(distance / window.visualViewport.scale);
// Scroll Vertically
await smoothScroll(distance,
x, y,
GestureSourceType.TOUCHPAD_INPUT,
'down',
SPEED_INSTANT,
precise_deltas);
assert_approx_equals(scroller.scrollTop, expected_scroll, floatPrecision);
// Scroll Horizontally
await smoothScroll(distance,
x, y,
GestureSourceType.TOUCHPAD_INPUT,
'right',
SPEED_INSTANT,
precise_deltas);
assert_approx_equals(scroller.scrollLeft, expected_scroll, floatPrecision);
}, 'Scrolling while zoomed scroller preserves fractional offsets.');
});
</script>