<!DOCTYPE html>
<title>Tests mouse interactions on a non-custom composited root scrollbar.</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>
<script src="../../../resources/testdriver.js"></script>
<script src="../../../resources/testdriver-actions.js"></script>
<script src="../../../resources/testdriver-vendor.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 SCROLL_CORNER = TRACK_WIDTH;
let SCROLL_AMOUNT_Y = internals.runtimeFlags.percentBasedScrollingEnabled ?
document.scrollingElement.clientHeight * SCROLLBAR_SCROLL_PERCENTAGE : SCROLLBAR_SCROLL_PIXELS;
if (!internals.runtimeFlags.fractionalScrollOffsetsEnabled)
SCROLL_AMOUNT_Y = Math.floor(SCROLL_AMOUNT_Y);
let SCROLL_AMOUNT_X = internals.runtimeFlags.percentBasedScrollingEnabled ?
document.scrollingElement.clientWidth * SCROLLBAR_SCROLL_PERCENTAGE : SCROLLBAR_SCROLL_PIXELS;
if (!internals.runtimeFlags.fractionalScrollOffsetsEnabled)
SCROLL_AMOUNT_X = Math.floor(SCROLL_AMOUNT_X);
promise_test (async (test) => {
// Scrollbars on Mac don't have arrows. This test is irrelevant.
if(navigator.userAgent.includes("Mac OS X"))
return;
await waitForCompositorCommit();
await waitForScrollReset(document.scrollingElement);
// Click on the Down arrow of the viewport.
let x = window.innerWidth - BUTTON_WIDTH / 2;
let y = window.innerHeight - SCROLL_CORNER - BUTTON_WIDTH / 2;
await clickAndWaitForScroll(x, y);
assert_equals(window.scrollY, SCROLL_AMOUNT_Y, "Pressing the down arrow didn't scroll.");
// Click on the Up arrow of the viewport.
x = window.innerWidth - BUTTON_WIDTH / 2;
y = BUTTON_WIDTH / 2;
await clickAndWaitForScroll(x, y);
assert_equals(window.scrollY, 0, "Pressing the up arrow didn't scroll.");
// Click on the Right arrow of the viewport.
x = window.innerWidth - SCROLL_CORNER - BUTTON_WIDTH / 2;
y = window.innerHeight - BUTTON_WIDTH / 2;
await clickAndWaitForScroll(x, y);
assert_equals(window.scrollX, SCROLL_AMOUNT_X, "Pressing the right arrow didn't scroll.");
// Click on the Left arrow of the viewport.
x = BUTTON_WIDTH / 2;
y = window.innerHeight - BUTTON_WIDTH / 2;
await clickAndWaitForScroll(x, y);
assert_equals(window.scrollX, 0, "Pressing the left arrow didn't scroll.");
}, "Test mouse click on non-custom composited root scrollbar arrows.");
promise_test (async () => {
await waitForCompositorCommit();
await waitForScrollReset(document.scrollingElement);
// Click on the track part just above the down arrow.
let x = window.innerWidth - BUTTON_WIDTH / 2;
let y = window.innerHeight - SCROLL_CORNER - BUTTON_WIDTH - 2;
await clickAndWaitForScroll(x, y);
assert_equals(window.scrollY, 431,
"Pressing the down trackpart didn't scroll.");
// Click on the track part just below the up arrow.
x = window.innerWidth - BUTTON_WIDTH / 2;
y = BUTTON_WIDTH + 2;
await clickAndWaitForScroll(x, y);
assert_equals(window.scrollY, 0,
"Pressing the up trackpart didn't scroll.");
// Click on the track part just to the left of the right arrow.
x = window.innerWidth - SCROLL_CORNER - BUTTON_WIDTH - 2;
y = window.innerHeight - BUTTON_WIDTH / 2;
await clickAndWaitForScroll(x, y);
assert_equals(window.scrollX, 223,
"Pressing the right trackpart didn't scroll.");
// Click on the track part just to the right of the left arrow.
x = BUTTON_WIDTH + 2;
y = window.innerHeight - BUTTON_WIDTH / 2;
await clickAndWaitForScroll(x, y);
assert_equals(window.scrollX, 0, "Pressing the left trackpart didn't scroll.");
}, "Test mouse click on non-custom composited root scrollbar empty trackparts.");
}
</script>
</body>