Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

test(interaction-harness): no wheel re-takes; delete retakeOnWheelPacing (#10549)

Christopher Chedeau9acc1b4492f7
diff --git a/internal/interaction-harness/README.md b/internal/interaction-harness/README.md
index e9149a7f85..c628da135a 100644
--- a/internal/interaction-harness/README.md
+++ b/internal/interaction-harness/README.md
@@ -606,9 +606,9 @@ the burst throws `WheelPageStallError`, the page split the gesture, and the
proof fails. A page can only widen a gap, so one no wider than the send
spacing is the dispatch's even when a starved renderer also held the step.
Otherwise the dispatch stalled before the page (a loaded runner) and it throws
-`WheelPacingError` with the gaps. Wrap such a
-proof in `retakeOnWheelPacing(testInfo, attempt)`: one re-take, only on
-`WheelPacingError`, listed as a `wheel-retake` annotation. The burst times the
+`WheelPacingError` with the gaps. A proof never re-takes itself: a
+`WheelPacingError` stays red, named as the runner's. Where one shows in CI's
+profile, fix the wheel's delivery, not the proof. The burst times the
page's handling with a listener on the window that runs after the page's own.
A step whose propagation the page stops is marked by a task queued when it
arrived, and never later than the next step's arrival. So its handling, with
diff --git a/internal/interaction-harness/src/harness.interaction.browser.spec.ts b/internal/interaction-harness/src/harness.interaction.browser.spec.ts
index 7184928b96..63f2efd3bf 100644
--- a/internal/interaction-harness/src/harness.interaction.browser.spec.ts
+++ b/internal/interaction-harness/src/harness.interaction.browser.spec.ts
@@ -102,7 +102,6 @@ import {
readLongTasks,
releaseAnimations,
requireFrames,
- retakeOnWheelPacing,
sampleCurve,
sampleRects,
seekAnimations,
@@ -305,15 +304,15 @@ test.describe('touch input', () => {
// behind such a send is off pace too. A runner whose CPU quota holds the
// test process also wakes the harness late from a wait, or holds a send,
// on a few moves (in a container capped at 3 CPUs, where the quota stalls
- // the process for about 100 ms at a time), so a take is off pace when
- // more than half its moves are. It is re-taken once, as wheel bursts are,
- // and a second such take fails. Under CPU starvation (a 3-CPU cap with 16
- // workers, with the software compositor's threads matched to the cap by
- // LP_NUM_THREADS), a pacer the cap throttles falls behind and need not
- // wait, so the pacing check can miss a slow pacer there (sending each step
- // at twice its time failed 8 of 20 runs), and the quota slows some sends
- // past the step's spacing, which reads like a harness whose send is slow
- // (the real test passed 40 of 40 there, re-taken 9 times).
+ // the process for about 100 ms at a time), so a take is off pace when more
+ // than half its moves are. It is re-taken once, and a second such take
+ // fails. Under CPU starvation (a 3-CPU cap with 16 workers, with the
+ // software compositor's threads matched to the cap by LP_NUM_THREADS), a
+ // pacer the cap throttles falls behind and need not wait, so the pacing
+ // check can miss a slow pacer there (sending each step at twice its time
+ // failed 8 of 20 runs), and the quota slows some sends past the step's
+ // spacing, which reads like a harness whose send is slow (the real test
+ // passed 40 of 40 there, re-taken 9 times).
for (const attempt of [1, 2] as const) {
const {played, answeredAt, playStart, log} = await take();
const {moves} = checkInput(log);
@@ -3101,7 +3100,7 @@ test.describe('wheel and pen input', () => {
}
});
- test('a wheel burst reaches the page as one run with its whole delta and no gap past the 100 ms a proof allows within a wheel gesture, re-taken once when the runner stalls it', async ({
+ test('a wheel burst reaches the page as one run with its whole delta and no gap past the 100 ms a proof allows within a wheel gesture', async ({
browser,
}) => {
const context = await browser.newContext({
@@ -3121,32 +3120,31 @@ test.describe('wheel and pen input', () => {
await page.goto('http://wheel-burst.test/');
const driver = await webInputDriver(page);
test.skip(!driver.wheels, WHEEL_SKIP);
- // A proof allows 100 ms between the steps of one wheel gesture: sent on
+ // A proof allows 100 ms between the steps of one wheel gesture. Sent on
// its schedule, the run stays one gesture however long each step's
- // round trip takes, and a runner stall past that bound is re-taken once.
- await retakeOnWheelPacing(test.info(), async () => {
- await page.evaluate(() => {
- (window as unknown as {__deltas: number[]}).__deltas = [];
- });
- const {receivedSteps, receivedGapsMs} = await driver.wheelBurst({
- x: 200,
- y: 300,
- steps: Array.from({length: 20}, () => ({dx: 40})),
- maxGapMs: 100,
- });
- // Every pixel arrives, in steps of 40 px or, where the engine
- // coalesced steps the page was still handling, their sums.
- const deltas = await page.evaluate(
- () => (window as unknown as {__deltas: number[]}).__deltas,
- );
- expect(deltas.reduce((sum, d) => sum + d, 0)).toBe(800);
- expect(
- deltas.every(d => d > 0 && d % 40 === 0),
- String(deltas),
- ).toBe(true);
- expect(receivedSteps).toBe(deltas.length);
- expect(receivedGapsMs).toHaveLength(receivedSteps - 1);
+ // round trip takes. A runner stall past that bound fails as
+ // WheelPacingError.
+ await page.evaluate(() => {
+ (window as unknown as {__deltas: number[]}).__deltas = [];
+ });
+ const {receivedSteps, receivedGapsMs} = await driver.wheelBurst({
+ x: 200,
+ y: 300,
+ steps: Array.from({length: 20}, () => ({dx: 40})),
+ maxGapMs: 100,
});
+ // Every pixel arrives, in steps of 40 px or, where the engine
+ // coalesced steps the page was still handling, their sums.
+ const deltas = await page.evaluate(
+ () => (window as unknown as {__deltas: number[]}).__deltas,
+ );
+ expect(deltas.reduce((sum, d) => sum + d, 0)).toBe(800);
+ expect(
+ deltas.every(d => d > 0 && d % 40 === 0),
+ String(deltas),
+ ).toBe(true);
+ expect(receivedSteps).toBe(deltas.length);
+ expect(receivedGapsMs).toHaveLength(receivedSteps - 1);
} finally {
await context.close();
}
@@ -3155,9 +3153,8 @@ test.describe('wheel and pen input', () => {
test('a wheel burst sent slower than its maxGapMs throws WheelPacingError, in both engines', async ({
browser,
}) => {
- // The negative control for the pacing check the re-take relies on: steps
- // 180 ms apart, on a page that handles each at once, against a 100 ms
- // bound.
+ // The negative control for the pacing check: steps 180 ms apart, on a page
+ // that handles each at once, against a 100 ms bound.
const context = await browser.newContext({
viewport: {width: 402, height: 714},
isMobile: false,
@@ -3227,7 +3224,7 @@ test.describe('wheel and pen input', () => {
}
});
- test('a page whose wheel listener holds its main thread splits a burst itself: never a runner stall, never re-taken', async ({
+ test('a page whose wheel listener holds its main thread splits a burst itself: never a runner stall', async ({
browser,
browserName,
}) => {
@@ -3248,25 +3245,18 @@ test.describe('wheel and pen input', () => {
await page.goto('http://wheel-stalling-page.test/');
const driver = await webInputDriver(page);
test.skip(!driver.wheels, WHEEL_SKIP);
- const testInfo = {
- annotations: [] as {type: string; description?: string}[],
- };
- const attempts: number[] = [];
- const outcome = await retakeOnWheelPacing(testInfo, async n => {
- attempts.push(n);
- return driver.wheelBurst({
+ const outcome = await driver
+ .wheelBurst({
x: 200,
y: 300,
steps: Array.from({length: 4}, () => ({dx: 10})),
maxGapMs: 100,
- });
- }).then(
- () => 'resolved',
- (error: unknown) => error,
- );
+ })
+ .then(
+ () => 'resolved',
+ (error: unknown) => error,
+ );
expect(outcome).not.toBeInstanceOf(WheelPacingError);
- expect(attempts).toEqual([1]);
- expect(testInfo.annotations).toEqual([]);
if (browserName === 'webkit') {
// WebKit dispatches the next step only once the page is free, so the
// page's stall widens the gaps, and the error names it.
@@ -3278,7 +3268,7 @@ test.describe('wheel and pen input', () => {
}
});
- test('a page whose wheel listener stops the step and holds its main thread still splits a burst itself: never re-taken', async ({
+ test('a page whose wheel listener stops the step and holds its main thread still splits a burst itself', async ({
browser,
browserName,
}) => {
@@ -3300,24 +3290,18 @@ test.describe('wheel and pen input', () => {
await page.goto('http://wheel-stopping-page.test/');
const driver = await webInputDriver(page);
test.skip(!driver.wheels, WHEEL_SKIP);
- const testInfo = {
- annotations: [] as {type: string; description?: string}[],
- };
- const attempts: number[] = [];
- const outcome = await retakeOnWheelPacing(testInfo, async n => {
- attempts.push(n);
- return driver.wheelBurst({
+ const outcome = await driver
+ .wheelBurst({
x: 200,
y: 300,
steps: Array.from({length: 4}, () => ({dx: 10})),
maxGapMs: 100,
- });
- }).then(
- () => 'resolved',
- (error: unknown) => error,
- );
+ })
+ .then(
+ () => 'resolved',
+ (error: unknown) => error,
+ );
expect(outcome).not.toBeInstanceOf(WheelPacingError);
- expect(attempts).toEqual([1]);
if (browserName === 'webkit') {
// The queued task marks the stopped step's handling, so the stall is
// the page's.
diff --git a/internal/interaction-harness/src/webInput.pacing.test.ts b/internal/interaction-harness/src/webInput.pacing.test.ts
index 51e2068630..f9f548e117 100644
--- a/internal/interaction-harness/src/webInput.pacing.test.ts
+++ b/internal/interaction-harness/src/webInput.pacing.test.ts
@@ -2,22 +2,20 @@
/**
* @file webInput.pacing.test.ts
- * @input webInput.ts's wheel pacing error and re-take
- * @output Unit cases: a wheel burst's steps arrive when the page received
- * them in WebKit and at their stamps in Chromium; its gaps past its bound
- * are the page's when its own handling of the step before caused them and
- * widened them past the harness's own send spacing, and the dispatch's
- * otherwise; each error names its gaps; and a proof is
- * re-taken once, only on a dispatch stall, with the re-take listed.
+ * @input webInput.ts's wheel pacing errors
+ * @output Unit cases. A wheel burst's steps arrive when the page received
+ * them in WebKit, and at their stamps in Chromium. A gap past its bound is
+ * the page's when two things hold. The page's handling of the step before
+ * caused it, and it is wider than the harness's send spacing. Otherwise the
+ * gap is the dispatch's. Each error names its gaps.
* @position Node unit tests beside the harness's browser self-tests.
*
* SYNC: When modified, update webInput.ts (wheelArrivals, wheelSendGaps, wheelGapCauses,
- * WheelPacingError, WheelPageStallError, retakeOnWheelPacing).
+ * WheelPacingError, WheelPageStallError).
*/
import {describe, expect, it} from 'vitest';
import {
- retakeOnWheelPacing,
wheelArrivals,
wheelGapCauses,
wheelSendGaps,
@@ -214,71 +212,3 @@ describe('WheelPageStallError', () => {
expect(error).not.toBeInstanceOf(WheelPacingError);
});
});
-
-describe('retakeOnWheelPacing', () => {
- const offPace = () => new WheelPacingError(100, [16, 120]);
-
- it('stays red when both attempts are off pace, with one re-take listed', async () => {
- const testInfo = {
- annotations: [] as {type: string; description?: string}[],
- };
- let attempts = 0;
- await expect(
- retakeOnWheelPacing(testInfo, async () => {
- attempts += 1;
- throw offPace();
- }),
- ).rejects.toBeInstanceOf(WheelPacingError);
- expect(attempts).toBe(2);
- expect(testInfo.annotations.map(a => a.type)).toEqual(['wheel-retake']);
- });
-
- it('never re-takes a product failure after input that kept its pace', async () => {
- const testInfo = {
- annotations: [] as {type: string; description?: string}[],
- };
- let attempts = 0;
- await expect(
- retakeOnWheelPacing(testInfo, async () => {
- attempts += 1;
- throw new Error('the gallery did not page');
- }),
- ).rejects.toThrow('the gallery did not page');
- expect(attempts).toBe(1);
- expect(testInfo.annotations).toEqual([]);
- });
-
- it('never re-takes a stall the page caused', async () => {
- const testInfo = {
- annotations: [] as {type: string; description?: string}[],
- };
- let attempts = 0;
- await expect(
- retakeOnWheelPacing(testInfo, async () => {
- attempts += 1;
- throw new WheelPageStallError(100, {gapMs: 152, handlingMs: 150});
- }),
- ).rejects.toBeInstanceOf(WheelPageStallError);
- expect(attempts).toBe(1);
- expect(testInfo.annotations).toEqual([]);
- });
-
- it('passes on a good second attempt after one off pace, and lists the re-take', async () => {
- const testInfo = {
- annotations: [] as {type: string; description?: string}[],
- };
- const seen: number[] = [];
- const result = await retakeOnWheelPacing(testInfo, async n => {
- seen.push(n);
- if (n === 1) {
- throw offPace();
- }
- return 'paged';
- });
- expect(result).toBe('paged');
- expect(seen).toEqual([1, 2]);
- expect(testInfo.annotations).toEqual([
- {type: 'wheel-retake', description: offPace().message},
- ]);
- });
-});
diff --git a/internal/interaction-harness/src/webInput.ts b/internal/interaction-harness/src/webInput.ts
index 9437579ce4..7cd3e639f3 100644
--- a/internal/interaction-harness/src/webInput.ts
+++ b/internal/interaction-harness/src/webInput.ts
@@ -44,7 +44,7 @@
* harness self-test (../src/harness.interaction.browser.spec.ts).
*/
-import type {CDPSession, JSHandle, Page, TestInfo} from '@playwright/test';
+import type {CDPSession, JSHandle, Page} from '@playwright/test';
import type {Engine} from './touch';
/** One wheel step: the page receives exactly `dx`, `dy` CSS px. */
@@ -85,8 +85,8 @@ export interface WheelBurst {
* page can only widen a gap, so a starved renderer that also held the step
* lands here). The dispatch stalled before the page, so a loaded runner
* splits what the driver sent as one gesture. Other work on the page's main
- * thread between steps (timers, frame callbacks) also lands here, so a
- * re-taken run is the runner's or that work's, never the wheel listeners'.
+ * thread between steps (timers, frame callbacks) also lands here. Such a
+ * stall is the runner's or that work's, never the wheel listeners'.
*/
export class WheelPacingError extends Error {
constructor(
@@ -106,7 +106,7 @@ export class WheelPacingError extends Error {
* listeners held the main thread, and WebKit dispatches the next step only
* once it is free. The handling time is page wall time, which on a starved
* runner includes the page's wait for a CPU. Judge a page stall from a run
- * with CI's CPU limits: there it is the proof's own failure, never re-taken.
+ * with CI's CPU limits: there it is the proof's own failure.
*/
export class WheelPageStallError extends Error {
constructor(
@@ -244,35 +244,6 @@ export function wheelGapCauses(
return {pageStalls, dispatchStalls};
}
-/**
- * Runs a wheel proof through `attempt`, and once more when the page received
- * its burst off pace: `attempt` builds the page's state, sends the burst with
- * `maxGapMs` and makes the spec's assertions, so a re-take starts over. One
- * re-take, two attempts in all, and only on a `WheelPacingError`: any other
- * error (a `WheelPageStallError`, which the page's wheel listeners caused,
- * among them), and a second `WheelPacingError`, fail the test with their own
- * cause. A `WheelPacingError` is the runner's or other work on the page's main
- * thread between steps, so a re-take does not clear the page of that work.
- * Each re-take is listed in the report as a `wheel-retake` annotation.
- */
-export async function retakeOnWheelPacing<T>(
- testInfo: Pick<TestInfo, 'annotations'>,
- attempt: (n: 1 | 2) => Promise<T>,
-): Promise<T> {
- try {
- return await attempt(1);
- } catch (error) {
- if (!(error instanceof WheelPacingError)) {
- throw error;
- }
- testInfo.annotations.push({
- type: 'wheel-retake',
- description: error.message,
- });
- return attempt(2);
- }
-}
-
/** A point of a pen stroke. */
export interface PenPoint {
readonly x: number;
diff --git a/packages/core/src/DateInput/__tests__/Wheel.interaction.browser.spec.ts b/packages/core/src/DateInput/__tests__/Wheel.interaction.browser.spec.ts
index c53a31c96d..67cd8bed1b 100644
--- a/packages/core/src/DateInput/__tests__/Wheel.interaction.browser.spec.ts
+++ b/packages/core/src/DateInput/__tests__/Wheel.interaction.browser.spec.ts
@@ -55,7 +55,6 @@ import {
type waitForAnimation,
waitForRest,
watchAnimations,
- retakeOnWheelPacing,
webInputDriver,
WHEEL_SKIP,
withStorybook,
@@ -1113,57 +1112,53 @@ test.describe('a mouse wheel and a trackpad (component:DateInput FR15)', () => {
test('a trackpad flick drives the touch column as a finger does: it follows, coasts on at the lift, and commits the row it rests on', async ({
page,
browserName,
- }, testInfo) => {
+ }) => {
test.skip(
browserName !== 'webkit',
"Chromium's driver sends each wheel as a mouse wheel's notch; only WebKit's sends a trackpad's precise deltas",
);
- await retakeOnWheelPacing(testInfo, async () => {
- const {field, at} = await openTouchColumn(page);
- const input = await webInputDriver(page);
- test.skip(!input.wheels, WHEEL_SKIP);
- // The fingers: 12 px a frame for 12 frames (144 px, five rows and a
- // bit), then the platform's momentum, a shrinking run.
- const fingers = Array.from({length: 12}, () => ({dy: 12}));
- const momentum = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1].map(dy => ({dy}));
- await input.wheelBurst({
- ...at,
- steps: [...fingers, ...momentum],
- maxGapMs: 100,
- });
- // It coasts on at UIKit's deceleration, well past the fingers'
- // travel and the momentum's (66 px), and commits where it rests.
- await expect
- .poll(async () => Number(await field.inputValue()), {timeout: 8000})
- .toBeGreaterThanOrEqual(10);
- const rested = await field.inputValue();
- await page.waitForTimeout(1000);
- await expect(field).toHaveValue(rested);
+ const {field, at} = await openTouchColumn(page);
+ const input = await webInputDriver(page);
+ test.skip(!input.wheels, WHEEL_SKIP);
+ // The fingers: 12 px a frame for 12 frames (144 px, five rows and a
+ // bit), then the platform's momentum, a shrinking run.
+ const fingers = Array.from({length: 12}, () => ({dy: 12}));
+ const momentum = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1].map(dy => ({dy}));
+ await input.wheelBurst({
+ ...at,
+ steps: [...fingers, ...momentum],
+ maxGapMs: 100,
});
+ // It coasts on at UIKit's deceleration, well past the fingers'
+ // travel and the momentum's (66 px), and commits where it rests.
+ await expect
+ .poll(async () => Number(await field.inputValue()), {timeout: 8000})
+ .toBeGreaterThanOrEqual(10);
+ const rested = await field.inputValue();
+ await page.waitForTimeout(1000);
+ await expect(field).toHaveValue(rested);
});
test('a slow trackpad drag that stops rests on the nearest row, without coasting', async ({
page,
browserName,
- }, testInfo) => {
+ }) => {
test.skip(
browserName !== 'webkit',
"Chromium's driver sends each wheel as a mouse wheel's notch; only WebKit's sends a trackpad's precise deltas",
);
- await retakeOnWheelPacing(testInfo, async () => {
- const {field, at} = await openTouchColumn(page);
- const input = await webInputDriver(page);
- test.skip(!input.wheels, WHEEL_SKIP);
- // 2 px a frame for 20 frames: 40 px, a row and a half less a bit.
- await input.wheelBurst({
- ...at,
- steps: Array.from({length: 20}, () => ({dy: 2})),
- maxGapMs: 100,
- });
- await expect(field).toHaveValue('01', {timeout: 5000});
- await page.waitForTimeout(1000);
- await expect(field).toHaveValue('01');
+ const {field, at} = await openTouchColumn(page);
+ const input = await webInputDriver(page);
+ test.skip(!input.wheels, WHEEL_SKIP);
+ // 2 px a frame for 20 frames: 40 px, a row and a half less a bit.
+ await input.wheelBurst({
+ ...at,
+ steps: Array.from({length: 20}, () => ({dy: 2})),
+ maxGapMs: 100,
});
+ await expect(field).toHaveValue('01', {timeout: 5000});
+ await page.waitForTimeout(1000);
+ await expect(field).toHaveValue('01');
});
});
});