Automatic update from web-platform-tests Fix timeout in mouse_wheel test Problems with the test: * potential to trigger input before the compositor is ready to handle the scroll * scroll amount was insufficient. Though a mouse-wheel scroll is directional, test-driver.scroll emulates a touchpad, which is not directional. Due to the margin-bottom, the distance between snap points is 110 and the initial scroll of 50 would snap back to the starting position. This was the source of the Timeout. * waitForAnimationEnd and waitForScrollTo resolve without an argument. Thus, the timestamp and evt were undefined. * No benefit to waiting to reach a scroll position separate from waiting for the scroll position to stabilize, as the stabilization must trigger at a time well after the last scroll is received. * A test that scrollend is received after the snap belongs in dom/event. * Assert_equals is problematic for scroll position since the position can be tweaked to align with a physical pixel boundary to reduce anti-aliasing. Bug: 40814982 Change-Id: I0ba377c7ca9c00d047ee020e1355625e2e1ccac4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6765747 Reviewed-by: David Awogbemila <awogbemila@chromium.org> Commit-Queue: Kevin Ellis <kevers@chromium.org> Cr-Commit-Position: refs/heads/main@{#1490359} -- wpt-commits: 9633ad67f55f8c06cfdb0604258582d3f5c21ab8 wpt-pr: 53866
67 lines
2.2 KiB
HTML
67 lines
2.2 KiB
HTML
<!DOCTYPE html>
|
|
<link rel="help" href="https://drafts.csswg.org/css-scroll-snap-1/#scroll-snap-type" />
|
|
<title>Mouse-wheel scroll snapping speed</title>
|
|
<meta name="assert"
|
|
content="Test passes if mousewheel snaps without pausing">
|
|
<style>
|
|
#scroller {
|
|
scroll-snap-type: block mandatory;
|
|
overflow: scroll;
|
|
height: 400px;
|
|
width: 400px
|
|
}
|
|
#space {
|
|
width: 200px;
|
|
height: 4000px;
|
|
}
|
|
.box {
|
|
scroll-snap-align: start;
|
|
background: blue;
|
|
margin-bottom: 10px;
|
|
width: 100px;
|
|
height: 100px;
|
|
}
|
|
</style>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="/resources/testdriver.js"></script>
|
|
<script src="/resources/testdriver-vendor.js"></script>
|
|
<script src="/resources/testdriver-actions.js"></script>
|
|
<script src="/dom/events/scrolling/scroll_support.js"></script>
|
|
<script src="../support/common.js"></script>
|
|
|
|
<div id="scroller">
|
|
<div class="box"></div>
|
|
<div id="target" class="box"></div>
|
|
<div id="space"></div>
|
|
</div>
|
|
<script>
|
|
promise_test(async t => {
|
|
await waitForCompositorReady();
|
|
const scroller = document.getElementById("scroller");
|
|
scroller.scrollTo(0, 0);
|
|
assert_equals(scroller.scrollTop, 0, "verify test pre-condition");
|
|
const scrollTop = () => {
|
|
return scroller.scrollTop;
|
|
};
|
|
const scrollPromise = waitForScrollEvent(scroller);
|
|
const wheelPromise = waitForWheelEvent(scroller);
|
|
const targetBounds =
|
|
document.getElementById('target').getBoundingClientRect();
|
|
const dy = targetBounds.top / 2 + 1;
|
|
const actions = new test_driver.Actions()
|
|
.scroll(50, 50, 0, dy, {origin: scroller, duration: 100});
|
|
await actions.send();
|
|
await wheelPromise;
|
|
await scrollPromise;
|
|
// Detect first pause in scrolling. As expected to snap right at the end of
|
|
// the scroll, there should be no appreciable pause before the snap takes
|
|
// place. Once the scrolling settles, we are expected to be at the snap
|
|
// position.
|
|
const scrollStabilizedPromise = waitForAnimationEnd(scrollTop);
|
|
await scrollStabilizedPromise;
|
|
assert_approx_equals(scroller.scrollTop, 110, 0.5,
|
|
'Failed to advance to next snap target');
|
|
}, "Wheel-scroll triggers snap to target position without intermediate pause.");
|
|
</script>
|