blob: a9536540861a9bcc44806547904fbe611e6761ce [file] [log] [blame]
<!DOCTYPE html>
<title>Tests mouse interactions on a non-custom composited root scrollbar thumb.</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../resources/gesture-util.js"></script>
<script src="../../../resources/scrollbar-util.js"></script>
<body style="height: 1000px; width: 1000px">
<script>
if (window.internals)
internals.settings.setScrollAnimatorEnabled(false);
window.onload = () => {
const TRACK_WIDTH = calculateScrollbarThickness();
const BUTTON_WIDTH = TRACK_WIDTH;
const onMacPlatform = navigator.userAgent.search(/\bMac OS X\b/) != -1;
promise_test (async () => {
await waitForCompositorCommit();
resetScrollOffset(document.scrollingElement);
// Testing the vertical scrollbar thumb.
let x = window.innerWidth - TRACK_WIDTH / 2;
let y = BUTTON_WIDTH + 10;
let asc_increments = [25, 10, 35, 7, 23];
let asc_offsets = [45, 64, 128, 141, 183];
let asc_offsets_mac = [43, 60, 121, 133, 173];
let desc_increments = [33, 11, 21, 5, 30];
let desc_offsets = [122, 102, 64, 55, 0];
let desc_offsets_mac = [116, 97, 60, 52, 0];
await mouseMoveTo(x, y);
await mouseDownAt(x, y);
// Scroll down
for (var i = 0; i < 5; i++){
y += asc_increments[i];
await mouseMoveTo(x, y);
const offset = onMacPlatform ? asc_offsets_mac[i] : asc_offsets[i];
if (internals.runtimeFlags.fractionalScrollOffsetsEnabled) {
assert_approx_equals(window.scrollY, offset, 1,
"Vertical thumb drag downwards did not scroll as expected at "+asc_increments[i]+" - ");
} else {
assert_equals(window.scrollY, offset,
"Vertical thumb drag downwards did not scroll as expected at "+asc_increments[i]+" - ");
}
};
// Scroll up
for (var i = 0; i < 5; i++){
y -= desc_increments[i];
await mouseMoveTo(x, y);
const offset = onMacPlatform ? desc_offsets_mac[i] : desc_offsets[i];
if (internals.runtimeFlags.fractionalScrollOffsetsEnabled) {
assert_approx_equals(window.scrollY, offset, 1,
"Vertical thumb drag upwards did not scroll as expected at "+desc_increments[i]+" - ");
} else {
assert_equals(window.scrollY, offset,
"Vertical thumb drag upwards did not scroll as expected at "+desc_increments[i]+" - ");
}
};
await mouseUpAt(x, y);
assert_equals(window.scrollY, 0, "Mouseup on vertical scrollbar thumb is not expected to scroll.");
// Since the horizontal scrolling is essentially the same codepath as vertical,
// this need not be tested in the interest of making the test run faster.
}, "Test mouse drags in increments on non-custom composited root scrollbar thumb.");
}
</script>
</body>