<!DOCTYPE html>
<title>Tests touch 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/blink-coordinates-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: 2000px; width: 2000px">
<script>
window.onload = () => {
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();
const SCROLL_AMOUNT =
getScrollbarButtonScrollDelta(document.scrollingElement);
// Tap on the Down arrow of the viewport.
let position = downArrow();
await touchTapScroll(position.x, position.y, document);
assert_equals(window.scrollY, SCROLL_AMOUNT.y,
"Pressing the down arrow didn't scroll.");
// Tap on the Up arrow of the viewport.
position = upArrow();
await touchTapScroll(position.x, position.y, document);
assert_equals(window.scrollY, 0,
"Pressing the up arrow didn't scroll.");
// Tap on the Right arrow of the viewport.
position = rightArrow();
await touchTapScroll(position.x, position.y, document);
assert_equals(window.scrollX, SCROLL_AMOUNT.x,
"Pressing the right arrow didn't scroll.");
// Tap on the Left arrow of the viewport.
position = leftArrow();
await touchTapScroll(position.x, position.y, document);
assert_equals(window.scrollX, 0,
"Pressing the left arrow didn't scroll.");
}, "Test tap on non-custom composited root scrollbar arrows.");
promise_test (async () => {
// Tap positions are based on having scrollbar buttons. Macs don't render
// scrollbar buttons let alone have touch screens so skip the test.
if(navigator.userAgent.includes("Mac OS X"))
return;
await waitForCompositorCommit();
await waitForScrollReset();
// Tap on the track part just above the down arrow.
let position = downArrow();
// Position is in center of the arrow button. Adjust to be just above.
const trackOffset = calculateScrollbarThickness() / 2 + 2;
position.y -= trackOffset;
await touchTapScroll(position.x, position.y, document);
assert_true(Math.abs(window.scrollY - 512) <= 1,
"Pressing the down trackpart didn't scroll.");
// Tap on the track part just below the up arrow.
position = upArrow();
position.y += trackOffset;
await touchTapScroll(position.x, position.y, document);
assert_equals(window.scrollY, 0,
"Pressing the up trackpart didn't scroll.");
// Tap on the track part just to the left of the right arrow.
position = rightArrow();
position.x -= trackOffset;
await touchTapScroll(position.x, position.y, document);
assert_true(Math.abs(window.scrollX - 687) <= 1,
"Pressing the right trackpart didn't scroll.");
// Tap on the track part just to the right of the left arrow.
position = leftArrow();
position.x += trackOffset;
await touchTapScroll(position.x, position.y, document);
assert_equals(window.scrollX, 0,
"Pressing the left trackpart didn't scroll.");
}, "Test tap on non-custom composited root scrollbar empty trackparts.");
}
</script>
</body>