<!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. Move the pointer to the edge of
// the scrollbar border to verify that capturing and dragging work across
// the whole width of the scrollbar track.
let x = window.innerWidth - 2;
let y = BUTTON_WIDTH + 10;
const asc_increments = [25, 10, 35, 7, 23];
const asc_offsets = [46, 64, 128, 141, 183];
// The Fluent scrollbar has one out of five offsets different from
// asc_offsets by 1px. All other ascending and descending offsets
// are the same.
const asc_offsets_fluent = [46, 64, 128, 141, 183];
const asc_offsets_mac = [43, 61, 122, 134, 174];
const desc_increments = [33, 11, 21, 5, 30];
const desc_offsets = [123, 103, 64, 55, 0];
const desc_offsets_mac = [116, 97, 61, 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, Buttons.LEFT);
const offset = onMacPlatform ? asc_offsets_mac[i] :
internals.runtimeFlags.fluentScrollbarsEnabled ?
asc_offsets_fluent[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, Buttons.LEFT);
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>