Skip to content

chore(server): pass action point/box as onBeforeInputAction args#40695

Open
dgozman wants to merge 5 commits intomicrosoft:mainfrom
dgozman:chore-input-action-observer
Open

chore(server): pass action point/box as onBeforeInputAction args#40695
dgozman wants to merge 5 commits intomicrosoft:mainfrom
dgozman:chore-input-action-observer

Conversation

@dgozman
Copy link
Copy Markdown
Collaborator

@dgozman dgozman commented May 7, 2026

Summary

  • Instrumentation.onBeforeInputAction now receives (sdkObject, metadata, point?, box?) instead of reading point/box off CallMetadata. Tracing, Screencast, and Recorder consume the arguments directly.
  • Drop annotate, box, and point from CallMetadata. Screencast computes a boundingBox itself for non-pointer actions; Recorder caches points by callId.
  • Add an optional { order: 'last' } to Instrumentation.addListener so the Debugger pause runs after other listeners — otherwise it blocks the recorder from capturing the action point while paused.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

} as const;

export interface InputActionObserver {
onBeforeInputAction(progress: Progress, target: Page | ElementHandle, point?: types.Point, box?: types.Rect): Promise<void>;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like our attribution, instrumentation, etc on the server side as a server-side implementation detail. You mostly touching the server here. The only thing that falls off it potentially, is tracing, but for that we need to pass tracing sink into the context.

dgozman added 4 commits May 8, 2026 13:36
Replace `Instrumentation.onBeforeInputAction` with a dedicated
`InputActionObserver` registered on `BrowserContext`. The observer
receives `(progress, target)` where target is `Page | ElementHandle`.
`Tracing`, `Debugger`, and `Screencast` register themselves on the
context and remove themselves on close/dispose.
Pass the optional bounding box as a third argument to
`performOnBeforeInputAction`. Pointer actions in `dom.ts` already
have the box from clickable-point computation; for non-pointer
actions on an `ElementHandle`, `Screencast` computes the box itself
when it needs one. This also lets `Screencast` stop being an
`InstrumentationListener` (its only use of `onBeforeCall` was
flipping the now-removed `annotate` flag) and inlines the small
`_beforeNonPointerAction` helper at its 5 call sites.
Pass the action point as a fourth argument to
`performOnBeforeInputAction(progress, target, point?, box?)`. Mouse,
touchscreen, and pointer-action call sites supply it directly;
`Screencast` and `Tracing` consume it from the argument instead of
reading `metadata.point`. The trace's after-action event no longer
carries a point (the input event still does, which is what trace
viewer reads). `Recorder` now registers as an `InputActionObserver`
and caches points by callId so the overlay can keep drawing the
action-point dot.
Debugger registered itself as an InputActionObserver in its constructor, so
it became the first observer (BrowserContext creates Debugger before any
other observer registers). Its pause is awaited inline, which prevented
later observers from running while paused — most importantly, Recorder
never got to record the action point in `_actionPoints`, so the
`x-pw-action-point` overlay never appeared. The `should highlight pointer,
only in main frame` test waits on that overlay and hung forever, keeping
its worker alive until the 90-min globalTimeout.

Drop Debugger from the observer set and invoke it explicitly at the end of
`performOnBeforeInputAction`, after all observers have recorded their state.
@dgozman dgozman force-pushed the chore-input-action-observer branch from 5964b14 to 70ce687 Compare May 8, 2026 13:40
@dgozman dgozman changed the title chore(server): introduce InputActionObserver on BrowserContext chore(server): pass action point/box as onBeforeInputAction args May 8, 2026
Drop the InputActionObserver interface on BrowserContext and put
onBeforeInputAction back on Instrumentation, with the new
(sdkObject, metadata, point?, box?) signature. Tracing, Screencast,
Recorder, and Debugger are once again InstrumentationListeners.

To preserve the run-last semantics for the debugger pause (so observers
like Recorder record action points before a pause blocks), addListener
takes an optional `{ order: 'last' }` and Debugger registers with it.
@dgozman dgozman force-pushed the chore-input-action-observer branch from 70ce687 to fd7eb0b Compare May 8, 2026 13:44
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Test results for "MCP"

6 failed
❌ [chrome] › mcp/annotate.spec.ts:57 › should capture multiple screenshots in one annotation @mcp-windows-latest-chrome
❌ [chrome] › mcp/annotate.spec.ts:110 › should abort annotation when last screenshot is removed @mcp-windows-latest-chrome
❌ [chrome] › mcp/annotate.spec.ts:137 › should abort MCP annotation when last screenshot is removed @mcp-windows-latest-chrome
❌ [chrome] › mcp/annotate.spec.ts:173 › user-initiated annotate downloads zip with feedback.md @mcp-windows-latest-chrome
❌ [webkit] › mcp/config.spec.ts:138 › browser_get_config returns merged config from file, env and cli @mcp-windows-latest-webkit
❌ [webkit] › mcp/test-run.spec.ts:126 › test_run should stop when aborted @mcp-windows-latest-webkit

7025 passed, 1068 skipped


Merge workflow run.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Test results for "tests 1"

3 flaky ⚠️ [chromium-library] › library/video.spec.ts:647 › screencast › should capture full viewport `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-page] › page/page-request-continue.spec.ts:756 › propagate headers cross origin redirect after interception `@chromium-ubuntu-22.04-node20`
⚠️ [chromium-library] › library/popup.spec.ts:261 › should not throw when click closes popup `@chromium-ubuntu-22.04-node22`

41693 passed, 850 skipped


Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants