Skip to content

Conversation

@Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Aug 14, 2025

Adds a private method for launching a playwright server for an existing browser, for usage from inside MCP.

@Skn0tt Skn0tt requested a review from dgozman August 14, 2025 08:27
@Skn0tt Skn0tt self-assigned this Aug 14, 2025
},

onConnection: (request, url, ws, id) => {
if (url.searchParams.has('debug-controller')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we don't want this available on every server, so let's make it configurable.

import { connectOverWebSocket } from './webSocket';
import { TimeoutSettings } from './timeoutSettings';

import type { Browser as BrowserImpl } from '../server/browser';
Copy link
Contributor

Choose a reason for hiding this comment

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

I think everything goes wrong with the bots because we should not import server code from the client side. I'd recommend making launchServerOnExistingBrowser taking a client-side Browser instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

i tried that in 820fd7f, but typescript still doesn't like it. how curious 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

oh, the real problem was that I imported from src instead of lib in a test.

@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.

@github-actions

This comment has been minimized.

host?: string,
port?: number,
wsPath?: string,
debugController?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Keep it private please.

Suggested change
debugController?: boolean;
_debugController?: boolean;

try {
const connection = this._delegate.onConnection(request, url, ws, id);
(ws as any)[kConnectionSymbol] = connection;
} catch (error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Lovely! I was about to comment that we should handle exceptions 😄

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

Test results for "tests 1"

2 failed
❌ [playwright-test] › playwright.reuse.browser.spec.ts:102 › should produce correct test steps @ubuntu-latest-node24-1
❌ [webkit-page] › page/page-navigation.spec.ts:20 › should work with _blank target @webkit-ubuntu-22.04-node18

21 flaky ⚠️ [chromium-library] › library/debug-controller.spec.ts:364 › should work with browser._launchServer `@chromium-ubuntu-22.04-node18`
⚠️ [chromium-library] › library/page-clock.frozen.spec.ts:19 › clock should be frozen `@chromium-ubuntu-22.04-node18`
⚠️ [chromium-library] › library/debug-controller.spec.ts:364 › should work with browser._launchServer `@chromium-ubuntu-22.04-node20`
⚠️ [chromium-library] › library/page-clock.frozen.spec.ts:19 › clock should be frozen `@chromium-ubuntu-22.04-node20`
⚠️ [chromium-library] › library/debug-controller.spec.ts:364 › should work with browser._launchServer `@chromium-ubuntu-22.04-node22`
⚠️ [chromium-library] › library/page-close.spec.ts:22 › should close page with active dialog `@chromium-ubuntu-22.04-node22`
⚠️ [chromium-library] › library/debug-controller.spec.ts:364 › should work with browser._launchServer `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-library] › library/page-close.spec.ts:22 › should close page with active dialog `@chromium-ubuntu-22.04-node24`
⚠️ [firefox-library] › library/debug-controller.spec.ts:364 › should work with browser._launchServer `@firefox-ubuntu-22.04-node18`
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1079 › cli codegen › should not throw csp directive violation errors `@firefox-ubuntu-22.04-node18`
⚠️ [firefox-library] › library/inspector/cli-codegen-aria.spec.ts:76 › should update aria snapshot highlight `@firefox-ubuntu-22.04-node18`
⚠️ [firefox-library] › library/inspector/cli-codegen-pick-locator.spec.ts:23 › should inspect locator `@firefox-ubuntu-22.04-node18`
⚠️ [firefox-library] › library/inspector/cli-codegen-pick-locator.spec.ts:35 › should update locator highlight `@firefox-ubuntu-22.04-node18`
⚠️ [firefox-page] › page/page-event-request.spec.ts:182 › should return response body when Cross-Origin-Opener-Policy is set `@firefox-ubuntu-22.04-node18`
⚠️ [firefox-page] › page/page-wait-for-function.spec.ts:104 › should work with strict CSP policy `@firefox-ubuntu-22.04-node18`
⚠️ [playwright-test] › ui-mode-trace.spec.ts:397 › should work behind reverse proxy `@macos-latest-node18-1`
⚠️ [chromium-library] › library/debug-controller.spec.ts:364 › should work with browser._launchServer `@ubuntu-22.04-chromium-tip-of-tree`
⚠️ [chromium-library] › library/inspector/recorder-api.spec.ts:49 › should click `@ubuntu-22.04-chromium-tip-of-tree`
⚠️ [webkit-library] › library/debug-controller.spec.ts:364 › should work with browser._launchServer `@webkit-ubuntu-22.04-node18`
⚠️ [webkit-library] › library/inspector/cli-codegen-2.spec.ts:24 › cli codegen › should contain open page `@webkit-ubuntu-22.04-node18`
⚠️ [webkit-page] › page/page-navigation.spec.ts:28 › should work with cross-process _blank target `@webkit-ubuntu-22.04-node18`

46594 passed, 803 skipped


Merge workflow run.

@Skn0tt Skn0tt merged commit 3fdbc06 into microsoft:main Aug 15, 2025
30 of 32 checks passed
Skn0tt added a commit to Skn0tt/playwright that referenced this pull request Oct 1, 2025
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