Skip to content

Commit 34b8c3d

Browse files
committed
Bug 1978352 [wpt PR 53866] - Fix timeout in mouse_wheel test, a=testonly
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 <awogbemilachromium.org> Commit-Queue: Kevin Ellis <keverschromium.org> Cr-Commit-Position: refs/heads/main{#1490359} -- wpt-commits: 9633ad67f55f8c06cfdb0604258582d3f5c21ab8 wpt-pr: 53866 UltraBlame original commit: a4dba8bfbf3c06d3525cc5fde707a941a7ae2069
1 parent 135587a commit 34b8c3d

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

testing/web-platform/tests/css/css-scroll-snap/input/mouse-wheel.html

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@
2727
<script src="/resources/testdriver.js"></script>
2828
<script src="/resources/testdriver-vendor.js"></script>
2929
<script src="/resources/testdriver-actions.js"></script>
30+
<script src="/dom/events/scrolling/scroll_support.js"></script>
3031
<script src="../support/common.js"></script>
32+
3133
<div id="scroller">
3234
<div class="box"></div>
33-
<div class="box"></div>
35+
<div id="target" class="box"></div>
3436
<div id="space"></div>
3537
</div>
3638
<script>
3739
promise_test(async t => {
40+
await waitForCompositorReady();
3841
const scroller = document.getElementById("scroller");
3942
scroller.scrollTo(0, 0);
4043
assert_equals(scroller.scrollTop, 0, "verify test pre-condition");
@@ -43,28 +46,21 @@
4346
};
4447
const scrollPromise = waitForScrollEvent(scroller);
4548
const wheelPromise = waitForWheelEvent(scroller);
49+
const targetBounds =
50+
document.getElementById('target').getBoundingClientRect();
51+
const dy = targetBounds.top / 2 + 1;
4652
const actions = new test_driver.Actions()
47-
.scroll(50, 50, 0, 50, {origin: scroller, duration: 100});
53+
.scroll(50, 50, 0, dy, {origin: scroller, duration: 100});
4854
await actions.send();
4955
await wheelPromise;
5056
await scrollPromise;
51-
let scrollEndTime;
52-
let snapEndTime;
53-
// Detect first pause in scrolling.
54-
const scrollStabilizedPromise =
55-
waitForAnimationEnd(scrollTop).then((timestamp) => {
56-
scrollEndTime = timestamp;
57-
});
58-
const snapEndPromise =
59-
waitForScrollTo(scroller, () => {
60-
return scroller.scrollTop;
61-
}, 110).then((evt) => {
62-
snapEndTime = evt.timestamp;
63-
});
64-
await Promise.all([scrollStabilizedPromise, snapEndPromise]);
65-
assert_equals(scroller.scrollTop, 110,
57+
// Detect first pause in scrolling. As expected to snap right at the end of
58+
// the scroll, there should be no appreciable pause before the snap takes
59+
// place. Once the scrolling settles, we are expected to be at the snap
60+
// position.
61+
const scrollStabilizedPromise = waitForAnimationEnd(scrollTop);
62+
await scrollStabilizedPromise;
63+
assert_approx_equals(scroller.scrollTop, 110, 0.5,
6664
'Failed to advance to next snap target');
67-
assert_true(snapEndTime < scrollEndTime,
68-
'Detected pause in scrolling before reaching snap target');
69-
}, "Wheel-scroll triggers snap to target position immediately.");
65+
}, "Wheel-scroll triggers snap to target position without intermediate pause.");
7066
</script>

0 commit comments

Comments
 (0)