Commit f0408b3a authored by Rahul Arakeri's avatar Rahul Arakeri Committed by Commit Bot

Re-enable tests and delete redundant code.

This CL updates some of the scrolling tests with platform specific test
expectations. (Since MockScrollbars no longer exist). The CL also gets
rid of duplicated tests without losing coverage.

Bug: 953847
Change-Id: I0bf10ef0434f9630624f73d9deb3986bd67661cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1925180Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Commit-Queue: Rahul Arakeri <arakeri@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#718331}
parent 28074dba
...@@ -640,6 +640,16 @@ crbug.com/980804 virtual/compositor_threaded_scrollbar_scrolling/fast/scrolling/ ...@@ -640,6 +640,16 @@ crbug.com/980804 virtual/compositor_threaded_scrollbar_scrolling/fast/scrolling/
crbug.com/980804 virtual/scroll_customization/fast/scrolling/scrollbars/mouse-autoscrolling-on-scrollbar.html [ Slow ] crbug.com/980804 virtual/scroll_customization/fast/scrolling/scrollbars/mouse-autoscrolling-on-scrollbar.html [ Slow ]
crbug.com/980804 virtual/threaded-prefer-compositing/fast/scrolling/scrollbars/mouse-autoscrolling-on-scrollbar.html [ Slow ] crbug.com/980804 virtual/threaded-prefer-compositing/fast/scrolling/scrollbars/mouse-autoscrolling-on-scrollbar.html [ Slow ]
crbug.com/980804 fast/scrolling/scrollbars/mouse-scrolling-on-div-scrollbar.html [ Slow ]
crbug.com/980804 virtual/compositor_threaded_scrollbar_scrolling/fast/scrolling/scrollbars/mouse-scrolling-on-div-scrollbar.html [ Slow ]
crbug.com/980804 virtual/scroll_customization/fast/scrolling/scrollbars/mouse-scrolling-on-div-scrollbar.html [ Slow ]
crbug.com/980804 virtual/threaded-prefer-compositing/fast/scrolling/scrollbars/mouse-scrolling-on-div-scrollbar.html [ Slow ]
crbug.com/980804 fast/scrolling/scrollbars/mouse-scrolling-on-root-scrollbar.html [ Slow ]
crbug.com/980804 virtual/compositor_threaded_scrollbar_scrolling/fast/scrolling/scrollbars/mouse-scrolling-on-root-scrollbar.html [ Slow ]
crbug.com/980804 virtual/scroll_customization/fast/scrolling/scrollbars/mouse-scrolling-on-root-scrollbar.html [ Slow ]
crbug.com/980804 virtual/threaded-prefer-compositing/fast/scrolling/scrollbars/mouse-scrolling-on-root-scrollbar.html [ Slow ]
crbug.com/983642 virtual/gpu/fast/canvas/canvas-composite-alpha.html [ Slow ] crbug.com/983642 virtual/gpu/fast/canvas/canvas-composite-alpha.html [ Slow ]
crbug.com/983642 [ Mac Debug ] fast/canvas/canvas-composite-alpha.html [ Slow ] crbug.com/983642 [ Mac Debug ] fast/canvas/canvas-composite-alpha.html [ Slow ]
crbug.com/983642 virtual/gpu/fast/canvas/canvas-composite-text-alpha.html [ Slow ] crbug.com/983642 virtual/gpu/fast/canvas/canvas-composite-text-alpha.html [ Slow ]
......
...@@ -2603,30 +2603,10 @@ crbug.com/332189 external/wpt/css/css-transitions/no-transition-from-ua-to-block ...@@ -2603,30 +2603,10 @@ crbug.com/332189 external/wpt/css/css-transitions/no-transition-from-ua-to-block
crbug.com/552085 external/wpt/css/css-cascade/important-prop.html [ Failure ] crbug.com/552085 external/wpt/css/css-cascade/important-prop.html [ Failure ]
# Failures on Mac scrollbars for compositor threaded scrollbar scrolling. # Failures on Mac scrollbars for compositor threaded scrollbar scrolling.
crbug.com/953847 [ Mac ] fast/scrolling/scrollbars/mouse-scrolling-on-div-scrollbar.html [ Failure ]
crbug.com/953847 [ Mac ] fast/scrolling/scrollbars/mouse-scrolling-on-root-scrollbar.html [ Failure ]
crbug.com/953847 [ Mac ] fast/scrolling/scrollbars/scroll-chaining-for-gesture-based-scrolling.html [ Failure ]
crbug.com/953847 [ Mac ] fast/scrolling/scrollbars/scrollbar-occluded-by-div.html [ Failure ]
crbug.com/953847 [ Mac ] fast/scrolling/scrollbars/scrollbar-button-gesture-target.html [ Failure ]
crbug.com/953847 [ Mac ] fast/scrolling/scrollbars/mouse-autoscrolling-on-scrollbar.html [ Failure Timeout ] crbug.com/953847 [ Mac ] fast/scrolling/scrollbars/mouse-autoscrolling-on-scrollbar.html [ Failure Timeout ]
crbug.com/953847 [ Mac ] virtual/compositor_threaded_scrollbar_scrolling/fast/scrolling/scrollbars/mouse-scrolling-on-div-scrollbar.html [ Failure ] crbug.com/953847 [ Mac ] virtual/threaded-prefer-compositing/fast/scrolling/scrollbars/mouse-autoscrolling-on-scrollbar.html [ Failure Timeout ]
crbug.com/953847 [ Mac ] virtual/compositor_threaded_scrollbar_scrolling/fast/scrolling/scrollbars/mouse-scrolling-on-root-scrollbar.html [ Failure ]
crbug.com/953847 [ Mac ] virtual/compositor_threaded_scrollbar_scrolling/fast/scrolling/scrollbars/scroll-chaining-for-gesture-based-scrolling.html [ Failure ]
crbug.com/953847 [ Mac ] virtual/compositor_threaded_scrollbar_scrolling/fast/scrolling/scrollbars/scrollbar-occluded-by-div.html [ Failure ]
crbug.com/953847 [ Mac ] virtual/compositor_threaded_scrollbar_scrolling/fast/scrolling/scrollbars/mouse-autoscrolling-on-scrollbar.html [ Failure Timeout ] crbug.com/953847 [ Mac ] virtual/compositor_threaded_scrollbar_scrolling/fast/scrolling/scrollbars/mouse-autoscrolling-on-scrollbar.html [ Failure Timeout ]
crbug.com/953847 [ Mac ] virtual/scroll_customization/fast/scrolling/scrollbars/mouse-scrolling-on-div-scrollbar.html [ Failure ]
crbug.com/953847 [ Mac ] virtual/scroll_customization/fast/scrolling/scrollbars/mouse-scrolling-on-root-scrollbar.html [ Failure ]
crbug.com/953847 [ Mac ] virtual/scroll_customization/fast/scrolling/scrollbars/scroll-chaining-for-gesture-based-scrolling.html [ Failure ]
crbug.com/953847 [ Mac ] virtual/scroll_customization/fast/scrolling/scrollbars/scrollbar-occluded-by-div.html [ Failure ]
crbug.com/953847 [ Mac ] virtual/scroll_customization/fast/scrolling/scrollbars/scrollbar-button-gesture-target.html [ Failure ]
crbug.com/953847 [ Mac ] virtual/scroll_customization/fast/scrolling/scrollbars/mouse-autoscrolling-on-scrollbar.html [ Failure Timeout ] crbug.com/953847 [ Mac ] virtual/scroll_customization/fast/scrolling/scrollbars/mouse-autoscrolling-on-scrollbar.html [ Failure Timeout ]
crbug.com/953847 [ Mac ] virtual/threaded-prefer-compositing/fast/scrolling/scrollbars/mouse-scrolling-on-div-scrollbar.html [ Failure ]
crbug.com/953847 [ Mac ] virtual/threaded-prefer-compositing/fast/scrolling/scrollbars/mouse-scrolling-on-root-scrollbar.html [ Failure ]
crbug.com/953847 [ Mac ] virtual/threaded-prefer-compositing/fast/scrolling/scrollbars/scroll-chaining-for-gesture-based-scrolling.html [ Failure ]
crbug.com/953847 [ Mac ] virtual/threaded-prefer-compositing/fast/scrolling/scrollbars/scrollbar-occluded-by-div.html [ Failure ]
crbug.com/953847 [ Mac ] virtual/threaded-prefer-compositing/fast/scrolling/scrollbars/scrollbar-button-gesture-target.html [ Failure ]
crbug.com/953847 [ Mac ] virtual/threaded-prefer-compositing/fast/scrolling/scrollbars/mouse-autoscrolling-on-scrollbar.html [ Failure Timeout ]
crbug.com/953847 [ Mac ] virtual/compositor_threaded_scrollbar_scrolling/fast/scrolling/scrollbars/scrollbar-button-gesture-target.html [ Failure ]
# 1px scroll offset difference for compositor threaded scrollbar scrolling on Linux. # 1px scroll offset difference for compositor threaded scrollbar scrolling on Linux.
crbug.com/1009892 [ Mac ] virtual/compositor_threaded_scrollbar_scrolling_hidpi/fast/scrolling/scrollbars/dsf-ready/mouse-interactions-dsf-2.html [ Failure Timeout ] crbug.com/1009892 [ Mac ] virtual/compositor_threaded_scrollbar_scrolling_hidpi/fast/scrolling/scrollbars/dsf-ready/mouse-interactions-dsf-2.html [ Failure Timeout ]
......
...@@ -104,21 +104,23 @@ window.onload = () => { ...@@ -104,21 +104,23 @@ window.onload = () => {
// Testing forward scroll on vertical scrollbar. Mac uses "Option" key // Testing forward scroll on vertical scrollbar. Mac uses "Option" key
// instead of "Shift". The Option key is mapped to "Alt" in GPUbenchmarking. // instead of "Shift". The Option key is mapped to "Alt" in GPUbenchmarking.
await mouseClickOn(SCROLLBAR_BUTTON_FWD.x, standardRectFast.top + 50, const modifier = onMacPlatform ? "Alt" : "Shift";
/*left_click*/0, /*modifier*/ onMacPlatform ? "Alt" : "Shift"); await mouseClickOn(SCROLLBAR_BUTTON_FWD.x, standardRectFast.top + 50, /*left_click*/0, modifier);
if (onMacPlatform) { let expected_offset = 0;
// TODO(arakeri): crbug.com/1019076 Option + click is off by 3-4 px. if (onLinuxPlatform)
assert_approx_equals(standardDivFast.scrollTop, 549, 3, expected_offset = window.devicePixelRatio == 1 ? 695 : 606;
"Option + click forward didn't scroll."); else if (onMacPlatform)
} else { expected_offset = 549;
let expected_offset = 0; else
if (onLinuxPlatform) expected_offset = window.devicePixelRatio == 1 ? 626 : 579.5;
expected_offset = window.devicePixelRatio == 1 ? 695 : 606;
else // TODO(arakeri): crbug.com/1019076 Option + click is off by 3-4 px.
expected_offset = window.devicePixelRatio == 1 ? 626 : 579.5; assert_approx_equals(standardDivFast.scrollTop, expected_offset, 3,
assert_equals(standardDivFast.scrollTop, expected_offset, modifier + " + click forward didn't scroll.");
"Shift + click forward didn't scroll.");
} await mouseClickOn(SCROLLBAR_BUTTON_FWD.x, standardRectFast.top +
((onMacPlatform ? 0 : BUTTON_WIDTH) + 2), /*left_click*/0, modifier);
assert_equals(standardDivFast.scrollTop, 0, modifier + " + click backward didn't scroll.");
}, "Test non-animated click scroll on non-custom composited scrollbars."); }, "Test non-animated click scroll on non-custom composited scrollbars.");
} }
</script> </script>
...@@ -61,9 +61,9 @@ ...@@ -61,9 +61,9 @@
if (window.internals) if (window.internals)
internals.settings.setScrollAnimatorEnabled(false); internals.settings.setScrollAnimatorEnabled(false);
// TODO(crbug.com/953847): Support other platforms or use calculated expectations.
let platform = navigator.userAgent.includes("Linux") ? "linux" : let platform = navigator.userAgent.includes("Linux") ? "linux" :
navigator.userAgent.includes("Windows") ? "win" : navigator.userAgent.includes("Windows") ? "win" :
navigator.userAgent.includes("Mac OS X") ? "mac" :
(() => { throw "Platform unsupported. See crbug.com/953847"; })(); (() => { throw "Platform unsupported. See crbug.com/953847"; })();
window.onload = () => { window.onload = () => {
...@@ -76,6 +76,10 @@ window.onload = () => { ...@@ -76,6 +76,10 @@ window.onload = () => {
const SCROLL_DELTA = 50; const SCROLL_DELTA = 50;
promise_test (async () => { promise_test (async () => {
// Scrollbars on Mac don't have arrows. This test is irrelevant.
if(platform == "mac")
return;
await waitForCompositorCommit(); await waitForCompositorCommit();
resetScrollOffset(standardDivFast); resetScrollOffset(standardDivFast);
...@@ -88,19 +92,19 @@ window.onload = () => { ...@@ -88,19 +92,19 @@ window.onload = () => {
// Click on the Up arrow for standardRectFast. // Click on the Up arrow for standardRectFast.
x = standardRectFast.right - BUTTON_WIDTH / 2; x = standardRectFast.right - BUTTON_WIDTH / 2;
y = standardRectFast.top + BUTTON_WIDTH / 2; y = standardRectFast.top + BUTTON_WIDTH / 2;
await mouseClickOn(x, y); await mouseClickOn(x, y);
assert_equals(standardDivFast.scrollTop, 0, "Pressing the up arrow didn't scroll."); assert_equals(standardDivFast.scrollTop, 0, "Pressing the up arrow didn't scroll.");
// Click on the Right arrow for standardRectFast. // Click on the Right arrow for standardRectFast.
x = standardRectFast.right - SCROLL_CORNER - BUTTON_WIDTH / 2; x = standardRectFast.right - SCROLL_CORNER - BUTTON_WIDTH / 2;
y = standardRectFast.bottom - BUTTON_WIDTH / 2; y = standardRectFast.bottom - BUTTON_WIDTH / 2;
await mouseClickOn(x, y); await mouseClickOn(x, y);
assert_equals(standardDivFast.scrollLeft, 40, "Pressing the right arrow didn't scroll."); assert_equals(standardDivFast.scrollLeft, 40, "Pressing the right arrow didn't scroll.");
// Click on the Left arrow for standardRectFast. // Click on the Left arrow for standardRectFast.
x = standardRectFast.left + BUTTON_WIDTH / 2; x = standardRectFast.left + BUTTON_WIDTH / 2;
y = standardRectFast.bottom - BUTTON_WIDTH / 2; y = standardRectFast.bottom - BUTTON_WIDTH / 2;
await mouseClickOn(x, y); await mouseClickOn(x, y);
assert_equals(standardDivFast.scrollLeft, 0, "Pressing the left arrow didn't scroll."); assert_equals(standardDivFast.scrollLeft, 0, "Pressing the left arrow didn't scroll.");
}, "Test mouse click on non-custom composited div scrollbar arrows."); }, "Test mouse click on non-custom composited div scrollbar arrows.");
...@@ -109,6 +113,7 @@ window.onload = () => { ...@@ -109,6 +113,7 @@ window.onload = () => {
resetScrollOffset(standardDivFast); resetScrollOffset(standardDivFast);
// Click on the track part just above the down arrow. // Click on the track part just above the down arrow.
assert_equals(standardDivFast.scrollTop, 0, "Div is not at 0 offset.");
let x = standardRectFast.right - BUTTON_WIDTH / 2; let x = standardRectFast.right - BUTTON_WIDTH / 2;
let y = standardRectFast.bottom - SCROLL_CORNER - BUTTON_WIDTH - 2; let y = standardRectFast.bottom - SCROLL_CORNER - BUTTON_WIDTH - 2;
await mouseClickOn(x, y); await mouseClickOn(x, y);
...@@ -116,61 +121,30 @@ window.onload = () => { ...@@ -116,61 +121,30 @@ window.onload = () => {
// Click on the track part just below the up arrow. // Click on the track part just below the up arrow.
x = standardRectFast.right - BUTTON_WIDTH / 2; x = standardRectFast.right - BUTTON_WIDTH / 2;
y = standardRectFast.top + BUTTON_WIDTH + 2; y = standardRectFast.top + (platform == "mac" ? 0 : BUTTON_WIDTH) + 2;
await mouseClickOn(x, y); await mouseClickOn(x, y);
assert_equals(standardDivFast.scrollTop, 0, "Pressing the up trackpart didn't scroll."); assert_equals(standardDivFast.scrollTop, 0, "Pressing the up trackpart didn't scroll.");
// Click on the track part just to the left of the right arrow. // Click on the track part just to the left of the right arrow.
x = standardRectFast.right - SCROLL_CORNER - BUTTON_WIDTH - 2; x = standardRectFast.right - SCROLL_CORNER - BUTTON_WIDTH - 2;
y = standardRectFast.bottom - BUTTON_WIDTH / 2; y = standardRectFast.bottom - BUTTON_WIDTH / 2;
await mouseClickOn(x, y); await mouseClickOn(x, y);
assert_equals(standardDivFast.scrollLeft, 74, "Pressing the right trackpart didn't scroll."); assert_equals(standardDivFast.scrollLeft, 74, "Pressing the right trackpart didn't scroll.");
// Click on the track part just to the right of the left arrow. // Click on the track part just to the right of the left arrow.
x = standardRectFast.left + BUTTON_WIDTH + 2; x = standardRectFast.left + (platform == "mac" ? 0 : BUTTON_WIDTH) + 2;
y = standardRectFast.bottom - BUTTON_WIDTH / 2; y = standardRectFast.bottom - BUTTON_WIDTH / 2;
await mouseClickOn(x, y); await mouseClickOn(x, y);
assert_equals(standardDivFast.scrollLeft, 0, "Pressing the left trackpart didn't scroll."); assert_equals(standardDivFast.scrollLeft, 0, "Pressing the left trackpart didn't scroll.");
}, "Test mouse click on non-custom composited div scrollbar empty trackparts."); }, "Test mouse click on non-custom composited div scrollbar empty trackparts.");
promise_test (async () => {
await waitForCompositorCommit();
resetScrollOffset(standardDivFast);
// Testing forward scroll on vertical scrollbar.
let x = standardRectFast.right - BUTTON_WIDTH / 2;
let y = standardRectFast.bottom - SCROLL_CORNER - BUTTON_WIDTH - 15;
await mouseClickOn(x, y, /*left_click*/0, /*modifier*/ "Shift");
let forward_offset = {linux: 915, win: 794}[platform];
assert_equals(standardDivFast.scrollTop, forward_offset, "Shift + click forward didn't scroll.");
// Testing backward scroll on vertical scrollbar.
x = standardRectFast.right - BUTTON_WIDTH / 2;
y = standardRectFast.top + BUTTON_WIDTH + 15;
let backward_offset = {linux: 0, win: 144}[platform];
await mouseClickOn(x, y, /*left_click*/0, /*modifier*/ "Shift");
assert_equals(standardDivFast.scrollTop, backward_offset, "Shift + click backward didn't scroll.");
// Testing forward scroll on horizontal scrollbar.
x = standardRectFast.right - SCROLL_CORNER - BUTTON_WIDTH - 15;
y = standardRectFast.bottom - BUTTON_WIDTH / 2;
await mouseClickOn(x, y, /*left_click*/0, /*modifier*/ "Shift");
assert_equals(standardDivFast.scrollLeft, forward_offset, "Shift + click forward didn't scroll.");
// Testing backward scroll on horizontal scrollbar.
x = standardRectFast.left + BUTTON_WIDTH + 15;
y = standardRectFast.bottom - BUTTON_WIDTH / 2;
await mouseClickOn(x, y, /*left_click*/0, /*modifier*/ "Shift");
assert_equals(standardDivFast.scrollLeft, backward_offset, "Shift + click backward didn't scroll.");
}, "Test shift + click on non-custom composited scrollbars.");
promise_test (async () => { promise_test (async () => {
await waitForCompositorCommit(); await waitForCompositorCommit();
resetScrollOffset(standardDivFast); resetScrollOffset(standardDivFast);
// Testing the vertical scrollbar thumb. // Testing the vertical scrollbar thumb.
let x = standardRectFast.right - TRACK_WIDTH / 2; let x = standardRectFast.right - TRACK_WIDTH / 2;
let y = standardRectFast.top + BUTTON_WIDTH + 5; let y = standardRectFast.top + (platform == "mac" ? 0 : BUTTON_WIDTH) + 2;
await mouseMoveTo(x, y); await mouseMoveTo(x, y);
await mouseDownAt(x, y); await mouseDownAt(x, y);
...@@ -181,43 +155,7 @@ window.onload = () => { ...@@ -181,43 +155,7 @@ window.onload = () => {
await mouseMoveTo(x, y); await mouseMoveTo(x, y);
assert_equals(standardDivFast.scrollTop, 0, "Vertical thumb drag beyond the track and back should not cause a scroll."); assert_equals(standardDivFast.scrollTop, 0, "Vertical thumb drag beyond the track and back should not cause a scroll.");
}, "Test thumb drags beyond scrollbar track.");
y += SCROLL_DELTA;
await mouseMoveTo(x, y);
assert_equals(standardDivFast.scrollTop, 915, "Vertical thumb drag downwards did not scroll as expected.");
y -= SCROLL_DELTA;
await mouseMoveTo(x, y);
assert_equals(standardDivFast.scrollTop, 0, "Vertical thumb drag upwards did not scroll as expected.");
await mouseUpAt(x, y);
assert_equals(standardDivFast.scrollTop, 0, "Mouseup on vertical scrollbar thumb is not expected to scroll.");
// Testing the horizontal scrollbar thumb.
x = standardRectFast.left + BUTTON_WIDTH + 5;
y = standardRectFast.bottom - TRACK_WIDTH / 2;
await mouseMoveTo(x, y);
await mouseDownAt(x, y);
assert_equals(standardDivFast.scrollLeft, 0, "Mousedown on horizontal scrollbar thumb is not expected to scroll.");
await mouseMoveTo(x-10, y);
assert_equals(standardDivFast.scrollLeft, 0, "Horizontal thumb drag beyond the track should not cause a scroll.");
await mouseMoveTo(x, y);
assert_equals(standardDivFast.scrollLeft, 0, "Horizontal thumb drag beyond the track and back should not cause a scroll.");
x += SCROLL_DELTA;
await mouseMoveTo(x, y);
assert_equals(standardDivFast.scrollLeft, 915, "Horizontal thumb drag towards the right did not scroll as expected.");
x -= SCROLL_DELTA;
await mouseMoveTo(x, y);
assert_equals(standardDivFast.scrollLeft, 0, "Horizontal thumb drag towards the left did not scroll as expected.");
await mouseUpAt(x, y);
assert_equals(standardDivFast.scrollLeft, 0, "Mouseup on horizontal scrollbar thumb is not expected to scroll.");
}, "Test mouse drags on non-custom composited div scrollbar thumb.");
promise_test (async () => { promise_test (async () => {
await waitForCompositorCommit(); await waitForCompositorCommit();
...@@ -225,11 +163,11 @@ window.onload = () => { ...@@ -225,11 +163,11 @@ window.onload = () => {
// Testing the vertical scrollbar thumb. // Testing the vertical scrollbar thumb.
let x = standardRectFast.right - TRACK_WIDTH / 2; let x = standardRectFast.right - TRACK_WIDTH / 2;
let y = standardRectFast.top + BUTTON_WIDTH + 5; let y = standardRectFast.top + (platform == "mac" ? 0 : BUTTON_WIDTH) + 2;
let asc_increments = [15, 10, 7, 6, 2]; let asc_increments = [15, 10, 7, 6, 2];
let asc_offsets = {linux: [549, 915, 915, 915, 915], win: [361, 601, 770, 915, 915]}[platform]; let asc_offsets = {linux: [549, 915, 915, 915, 915], win: [361, 601, 770, 915, 915], mac: [211, 351, 450, 534, 563]}[platform];
let desc_increments = [3, 2, 5, 9, 21]; let desc_increments = [3, 2, 5, 9, 21];
let desc_offsets = {linux: [915, 915, 915, 768, 0], win: [890, 842, 722, 505, 0]}[platform]; let desc_offsets = {linux: [915, 915, 915, 768, 0], win: [890, 842, 722, 505, 0], mac: [520, 492, 422, 295, 0]}[platform];
await mouseMoveTo(x, y); await mouseMoveTo(x, y);
await mouseDownAt(x, y); await mouseDownAt(x, y);
......
...@@ -14,8 +14,14 @@ window.onload = () => { ...@@ -14,8 +14,14 @@ window.onload = () => {
const BUTTON_WIDTH = TRACK_WIDTH; const BUTTON_WIDTH = TRACK_WIDTH;
const SCROLL_CORNER = TRACK_WIDTH; const SCROLL_CORNER = TRACK_WIDTH;
const SCROLL_DELTA = 100; const SCROLL_DELTA = 100;
const onLinuxPlatform = navigator.userAgent.search(/\bLinux\b/) != -1;
const onMacPlatform = navigator.userAgent.search(/\bMac OS X\b/) != -1;
promise_test (async (test) => {
// Scrollbars on Mac don't have arrows. This test is trrelevant.
if(onMacPlatform)
test.done();
promise_test (async () => {
await waitForCompositorCommit(); await waitForCompositorCommit();
resetScrollOffset(document.scrollingElement); resetScrollOffset(document.scrollingElement);
...@@ -90,43 +96,7 @@ window.onload = () => { ...@@ -90,43 +96,7 @@ window.onload = () => {
await mouseMoveTo(x, y); await mouseMoveTo(x, y);
assert_equals(window.scrollY, 0, "Vertical thumb drag beyond the track and back should not cause a scroll."); assert_equals(window.scrollY, 0, "Vertical thumb drag beyond the track and back should not cause a scroll.");
}, "Test thumb drags beyond scrollbar track.");
y += SCROLL_DELTA;
await mouseMoveTo(x, y);
assert_equals(window.scrollY, 183, 1, "Vertical thumb drag downwards did not scroll as expected.");
y -= SCROLL_DELTA;
await mouseMoveTo(x, y);
assert_equals(window.scrollY, 0, "Vertical thumb drag upwards did not scroll as expected.");
await mouseUpAt(x, y);
assert_equals(window.scrollY, 0, "Mouseup on vertical scrollbar thumb is not expected to scroll.");
// Testing the horizontal scrollbar thumb.
x = BUTTON_WIDTH + 10;
y = window.innerHeight - TRACK_WIDTH / 2;
await mouseMoveTo(x, y);
await mouseDownAt(x, y);
assert_equals(window.scrollX, 0, "Mousedown on horizontal scrollbar thumb is not expected to scroll.");
await mouseMoveTo(x-10, y);
assert_equals(window.scrollX, 0, "Horizontal thumb drag beyond the track should not cause a scroll.");
await mouseMoveTo(x, y);
assert_equals(window.scrollX, 0, "Horizontal thumb drag beyond the track and back should not cause a scroll.");
x += SCROLL_DELTA;
await mouseMoveTo(x, y);
assert_equals(window.scrollX, 133, 1, "Horizontal thumb drag towards the right did not scroll as expected.");
x -= SCROLL_DELTA;
await mouseMoveTo(x, y);
assert_equals(window.scrollX, 0, "Horizontal thumb drag towards the left did not scroll as expected.");
await mouseUpAt(x, y);
assert_equals(window.scrollX, 0, "Mouseup on horizontal scrollbar thumb is not expected to scroll.");
}, "Test mouse drags on non-custom composited root scrollbar thumb.");
promise_test (async () => { promise_test (async () => {
await waitForCompositorCommit(); await waitForCompositorCommit();
...@@ -137,8 +107,11 @@ window.onload = () => { ...@@ -137,8 +107,11 @@ window.onload = () => {
let y = BUTTON_WIDTH + 10; let y = BUTTON_WIDTH + 10;
let asc_increments = [25, 10, 35, 7, 23]; let asc_increments = [25, 10, 35, 7, 23];
let asc_offsets = [45, 64, 128, 141, 183]; 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_increments = [33, 11, 21, 5, 30];
let desc_offsets = [122, 102, 64, 55, 0]; let desc_offsets = [122, 102, 64, 55, 0];
let desc_offsets_mac = [116, 97, 60, 52, 0];
await mouseMoveTo(x, y); await mouseMoveTo(x, y);
await mouseDownAt(x, y); await mouseDownAt(x, y);
...@@ -147,14 +120,16 @@ window.onload = () => { ...@@ -147,14 +120,16 @@ window.onload = () => {
for (var i = 0; i < 5; i++){ for (var i = 0; i < 5; i++){
y += asc_increments[i]; y += asc_increments[i];
await mouseMoveTo(x, y); await mouseMoveTo(x, y);
assert_equals(window.scrollY, asc_offsets[i], "Vertical thumb drag downwards did not scroll as expected at "+asc_increments[i]+" - "); const offset = onMacPlatform ? asc_offsets_mac[i] : asc_offsets[i];
assert_equals(window.scrollY, offset, "Vertical thumb drag downwards did not scroll as expected at "+asc_increments[i]+" - ");
}; };
// Scroll up // Scroll up
for (var i = 0; i < 5; i++){ for (var i = 0; i < 5; i++){
y -= desc_increments[i]; y -= desc_increments[i];
await mouseMoveTo(x, y); await mouseMoveTo(x, y);
assert_equals(window.scrollY, desc_offsets[i], "Vertical thumb drag upwards did not scroll as expected at "+desc_increments[i]+" - "); const offset = onMacPlatform ? desc_offsets_mac[i] : desc_offsets[i];
assert_equals(window.scrollY, offset, "Vertical thumb drag upwards did not scroll as expected at "+desc_increments[i]+" - ");
}; };
await mouseUpAt(x, y); await mouseUpAt(x, y);
...@@ -167,7 +142,9 @@ window.onload = () => { ...@@ -167,7 +142,9 @@ window.onload = () => {
x = BUTTON_WIDTH + 10; x = BUTTON_WIDTH + 10;
y = window.innerHeight - TRACK_WIDTH / 2; y = window.innerHeight - TRACK_WIDTH / 2;
asc_offsets = [33, 46, 93, 102, 133]; asc_offsets = [33, 46, 93, 102, 133];
asc_offsets_mac = [32, 44, 89, 98, 128];
desc_offsets = [89, 74, 46, 40, 0]; desc_offsets = [89, 74, 46, 40, 0];
desc_offsets_mac = [85, 71, 44, 38, 0];
await mouseMoveTo(x, y); await mouseMoveTo(x, y);
await mouseDownAt(x, y); await mouseDownAt(x, y);
...@@ -177,14 +154,16 @@ window.onload = () => { ...@@ -177,14 +154,16 @@ window.onload = () => {
for (var i = 0; i < 5; i++){ for (var i = 0; i < 5; i++){
x += asc_increments[i]; x += asc_increments[i];
await mouseMoveTo(x, y); await mouseMoveTo(x, y);
assert_equals(window.scrollX, asc_offsets[i], "Horizontal thumb drag to the right did not scroll as expected at "+asc_increments[i]+" - "); const offset = onMacPlatform ? asc_offsets_mac[i] : asc_offsets[i];
assert_equals(window.scrollX, offset, "Horizontal thumb drag to the right did not scroll as expected at "+asc_increments[i]+" - ");
}; };
// Scroll left // Scroll left
for (var i = 0; i < 5; i++){ for (var i = 0; i < 5; i++){
x -= desc_increments[i]; x -= desc_increments[i];
await mouseMoveTo(x, y); await mouseMoveTo(x, y);
assert_equals(window.scrollX, desc_offsets[i], "Horizontal thumb drag to the left did not scroll as expected at "+desc_increments[i]+" - "); const offset = onMacPlatform ? desc_offsets_mac[i] : desc_offsets[i];
assert_equals(window.scrollX, offset, "Horizontal thumb drag to the left did not scroll as expected at "+desc_increments[i]+" - ");
}; };
await mouseUpAt(x, y); await mouseUpAt(x, y);
......
...@@ -27,7 +27,13 @@ ...@@ -27,7 +27,13 @@
<script> <script>
promise_test(async () => { promise_test(async (test) => {
// This specifically tests the impact of clicking the scrollbar button
// when scroller is at max offset. Since Mac scrollbars don't have any
// buttons, this test is irrelevant.
if(navigator.userAgent.search(/\bMac OS X\b/) != -1) {
test.done();
}
// Scroll the subscroller to the end, on the y-axis // Scroll the subscroller to the end, on the y-axis
let subscroller = document.querySelector(".subscroller"); let subscroller = document.querySelector(".subscroller");
subscroller.scrollTo(0, 400); subscroller.scrollTo(0, 400);
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
const BUTTON_WIDTH = TRACK_WIDTH; const BUTTON_WIDTH = TRACK_WIDTH;
const SCROLL_CORNER = TRACK_WIDTH; const SCROLL_CORNER = TRACK_WIDTH;
const PRESS_DURATION = 500; const PRESS_DURATION = 500;
const onMacPlatform = navigator.userAgent.search(/\bMac OS X\b/) != -1;
// This tests that interacting with a composited scrollbar that is // This tests that interacting with a composited scrollbar that is
// occluded by another layer doesn't cause a scroll. // occluded by another layer doesn't cause a scroll.
...@@ -69,6 +70,8 @@ ...@@ -69,6 +70,8 @@
// Remove the div and verify that scrolling takes place as expected. // Remove the div and verify that scrolling takes place as expected.
document.body.removeChild(occlusion_div); document.body.removeChild(occlusion_div);
await mouseClickOn(down_arrow_x, down_arrow_y); await mouseClickOn(down_arrow_x, down_arrow_y);
assert_equals(scroller.scrollTop, 40, "Pressing the down arrow didn't scroll."); const expected = onMacPlatform ? 74 : 40;
const pressedPart = onMacPlatform ? "track" : "down arrow";
assert_equals(scroller.scrollTop, expected, "Pressing the " + pressedPart + " didn't scroll.");
},"Test hit-testing when scrollbar is occluded."); },"Test hit-testing when scrollbar is occluded.");
</script> </script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment