Skip to content

feat(webmcp): add page.webmcp API - #42981

Merged
Pavel Feldman (pavelfeldman) merged 1 commit into
microsoft:mainfrom
pavelfeldman:web-mcp-3
Sep 29, 2026
Merged

Pavel Feldman (pavelfeldman) merged 1 commit into
microsoft:mainfrom
pavelfeldman:web-mcp-3

Conversation

@pavelfeldman

Copy link
Copy Markdown
Member

No description provided.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Hi, I'm the Playwright bot and I took a first look at the CI failures.

🟢 The one failure looks like a pre-existing flake

The only failure is reporter-html.spec.ts:3648 (speedboard) on macOS. It's an HTML-reporter UI test that this PR's page.webmcp changes don't reach, and it has flaked on the same bot before on another PR.

Details

This PR adds page.webmcp to the client, protocol, server, and Chromium code (crPage.ts, server/webmcp.ts) and refactors the MCP webmcp tool backend. It doesn't touch packages/html-reporter, the test runner, or the reporter tests. The latest report (run 36518047559) has 1 failure and 3 flaky tests, with 52,501 passing.

Pre-existing flake / infra

  • [playwright-test] › reporter-html.spec.ts:3648 › merged › speedboard › clicking on label should not exit speedboard (macos-latest-node22): I checked this test's history across the test-results DB. On macos-latest-node22 it failed on the first attempt in one of 638 runs and passed on retry. That run was on feat(tracing): allow configuring the screenshots size #42283 (feat(tracing): allow configuring the screenshots size, sha 9e5bdac), which this PR can't have caused. The error there was a toMatchAriaSnapshot timeout because the speedboard view had been left. It has 0 failures in ~4,500 runs on the other bots (ubuntu/windows, all Node versions), so it only flakes on macOS and only rarely. The test works on the HTML report UI, which this PR doesn't touch.

Flaky, not triaged (passed on retry): browsercontext-page-event.spec.ts:160 (chromium arm) and two Firefox browsercontext-cookies-third-party.spec.ts Partitioned-cookie tests. None of them touch WebMCP.

Caveat: refreshing the test-results snapshot failed because the GitHub API returned an error, so this PR's own run isn't in the DB. The earlier flake above comes from the existing snapshot.

Triaged by the Playwright bot - agent run

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Comment thread packages/playwright-core/src/server/page.ts Outdated
Comment thread packages/playwright-core/src/server/webmcp.ts
Comment thread packages/playwright-core/src/server/webmcp.ts
type DocumentWithModelContext = Document & { modelContext?: PageModelContext };
type NavigatorWithModelContext = Navigator & { modelContext?: PageModelContext };

function hookModelContext(bindingName: string, controllerProperty: string, registryProperty: string) {

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.

move this to injected scripts

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

3 failed
❌ [chromium] › mcp/sse.spec.ts:196 › sse transport browser lifecycle (persistent) @mcp-ubuntu-latest-chromium
❌ [firefox] › mcp/cli-core.spec.ts:97 › fill @mcp-windows-latest-firefox
❌ [firefox] › mcp/idle-timeout.spec.ts:19 › closes the browser after the idle timeout and relaunches it on the next call @mcp-windows-latest-firefox

8826 passed, 1480 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

3 flaky ⚠️ [chromium-library] › library/video.spec.ts:762 › screencast › should work with video+trace `@chromium-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:257 › third party 'Partitioned;' cookies `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:470 › top level 'Partitioned;' cookie and same origin iframe `@firefox-ubuntu-22.04-node20`

52520 passed, 1270 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Hi, I'm the Playwright bot and I took a first look at the CI failures.

🟢 All three MCP failures look like pre-existing flakes

Each failing test has also failed, on the same bot, on main pushes or unrelated PRs.

Details

The only MCP-side change in this PR is in tools/backend/tab.ts. It calls frame.webmcp.enable() per frame and catches any error. That path runs in every MCP test, and 8826 of them passed, so a regression there would show up much more widely than three one-off failures on separate bots. I couldn't get the error text out of the job logs, so this verdict rests on history. The results DB snapshot also couldn't be refreshed (GitHub API 500), so the latest runs aren't in it.

Pre-existing flake / infra

Triaged by the Playwright bot - agent 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