Skip to content

Commit 0e19d71

Browse files
David Awogbemilachromium-wpt-export-bot
David Awogbemila
authored andcommitted
Make flaky snap fling test fail quickly
The flaky test in the linked bug appears to be timing out while waiting for a scrollend event. This patch modifies the test to listen for pointer events which signal whether or not a scroll is happening and allows us to fail/bail early instead of wait for a timeout. Bug: 380534434 Change-Id: I2d203cc44b93e8c4c83f9644748916c1d65acbf7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6049312 Reviewed-by: Kevin Ellis <[email protected]> Commit-Queue: David Awogbemila <[email protected]> Cr-Commit-Position: refs/heads/main@{#1388805}
1 parent 9d67a4a commit 0e19d71

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

css/css-scroll-snap/snap-fling-in-large-area.html

+19-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,25 @@
4444
last_scroll_top = scroller.scrollTop;
4545
}
4646
scroller.addEventListener("scroll", scroll_listener);
47-
const scrollend_promise = waitForScrollendEventNoTimeout(scroller);
48-
await touchFlingInTarget(/*pixels_to_scroll*/100, scroller, "down");
49-
await scrollend_promise;
47+
// We expect pointercancel to be triggered when scrolling starts due to
48+
// the touch-fling. If we instead get a pointerup event, we know that
49+
// scrolling isn't happening and we can immediately fail the test instead
50+
// of waiting for a timeout.
51+
const pointer_promise = () => {
52+
return new Promise((resolve, reject) => {
53+
document.addEventListener("pointerup", reject, { once: true });
54+
document.addEventListener("pointercancel", resolve, { once: true });
55+
});
56+
};
57+
58+
try {
59+
const scrollend_promise = waitForScrollendEventNoTimeout(scroller);
60+
await touchFlingInTarget(/*pixels_to_scroll*/100, scroller, "down");
61+
await pointer_promise;
62+
await scrollend_promise;
63+
} catch(e) {
64+
assert_unreached("Failed to trigger touch fling.");
65+
}
5066

5167
assert_greater_than(last_scroll_top, initial_scroll_top,
5268
"received at least one scroll update.");

0 commit comments

Comments
 (0)