Files
iptvnator/apps/electron-backend-e2e/src/keyboard-scroll.ts
T
4grayandClaude Opus 5.5 633fde3e0e test(e2e): wait for scrollend between scroll keys (#1893)
Chromium drops a keyboard scroll pressed in the frame or two after the
previous smooth scroll lands but before Blink handles the compositor's
finish: ScrollAnimator retargets the finished curve
(kRunningOnCompositorButNeedsUpdate), then the late
CompositorAnimationFinished treats that state as finished and resets it.

The Live TV responsiveness spec pressed the next key as soon as an
expect.poll saw scrollTop change, so a poll that sampled the final frame
sent PageDown or Home into that window (2 of 5 local runs on master, all
three CI attempts on PR #1886).

pressScrollKey presses a scroll key and waits for that scroll's
scrollend. The Live TV spec uses it for PageDown, PageDown and Home with
the same position assertions; the VOD detail spec swaps its stable-frame
fence for it. The validation map documents the race.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 14:04:48 +02:00

42 lines
1.3 KiB
TypeScript

import { expect, Locator, Page } from '@playwright/test';
type ScrollEndProbe = Element & { e2eScrollEnded?: boolean };
/**
* Press a key that scrolls `scroller`, then wait for that scroll's `scrollend`.
*
* Chromium drops a keyboard scroll pressed in the frame or two between the
* compositor finishing the previous smooth scroll and Blink handling that
* finish: the key retargets the finished animation, and the late finish
* notification then resets it. The final `scrollTop` arrives before that
* notification, so the next discrete scroll input waits for `scrollend`
* instead. The key must scroll; a key that does not fails here.
*/
export async function pressScrollKey(
page: Page,
scroller: Locator,
key: string
): Promise<void> {
await scroller.evaluate((element) => {
const probe = element as ScrollEndProbe;
probe.e2eScrollEnded = false;
element.addEventListener(
'scrollend',
() => {
probe.e2eScrollEnded = true;
},
{ once: true }
);
});
await page.keyboard.press(key);
await expect
.poll(
() =>
scroller.evaluate(
(element) => (element as ScrollEndProbe).e2eScrollEnded
),
{ message: `${key} scroll ended` }
)
.toBe(true);
}