-
Notifications
You must be signed in to change notification settings - Fork 663
Playwright Browser Server #5424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
4e78a35 to
7956637
Compare
…m/microsoft/rushstack into bmiddha/playwright-browser-server
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces the Playwright Browser Server, a CLI-based tool that enables headful browser testing in VS Code remote environments (Codespaces, WSL, VS Code Tunnels) by tunneling Playwright WebSocket control messages over VS Code port forwarding.
Key changes:
- Adds
@rushstack/playwright-browser-tunnelpackage implementing the browser tunnel server and client connection logic - Introduces
playwright-on-codespacesVS Code extension that polls for connections and launches local browsers - Implements bidirectional WebSocket forwarding between remote Playwright tests and local browser instances
Reviewed changes
Copilot reviewed 32 out of 37 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/playwright-browser-tunnel/src/PlaywrightBrowserTunnel.ts | Core tunnel implementation handling connection polling, browser server setup, and WebSocket forwarding |
| apps/playwright-browser-tunnel/src/tunneledBrowserConnection.ts | Client-side tunnel connection logic with handshake protocol and message buffering |
| apps/playwright-browser-tunnel/tests/testFixture.ts | Playwright test fixture that integrates the tunneled browser connection |
| vscode-extensions/playwright-on-codespaces-vscode-extension/src/extension.ts | VS Code extension that manages tunnel lifecycle with status bar UI and command palette integration |
| apps/playwright-browser-tunnel/package.json | Package configuration for the browser tunnel tool |
| rush.json | Registers new projects in Rush monorepo |
| common/config/rush/*-approved-packages.json | Approves Playwright dependencies for use in the monorepo |
Files not reviewed (1)
- common/config/subspaces/default/pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)
vscode-extensions/playwright-on-codespaces-vscode-extension/src/extension.ts:1
- Corrected spelling of 'Exension' to 'Extension'.
vscode-extensions/playwright-on-codespaces-vscode-extension/LICENSE
Outdated
Show resolved
Hide resolved
apps/playwright-browser-tunnel/src/tunneledBrowserConnection.ts
Outdated
Show resolved
Hide resolved
…bpack.config.js Co-authored-by: Ian Clanton-Thuon <iclanton@users.noreply.github.com>
…m/microsoft/rushstack into bmiddha/playwright-browser-server
|
@TheLarkInn I've opened a new pull request, #5555, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@TheLarkInn I've opened a new pull request, #5556, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@TheLarkInn I've opened a new pull request, #5557, to work on those changes. Once the pull request is ready, I'll request review from you. |
…5557) * Initial plan * Read IP address from server.address() and handle IPv6 formatting Co-authored-by: TheLarkInn <3408176+TheLarkInn@users.noreply.github.com> * Use 'localhost' instead of hardcoded IPv4 to allow system to choose IPv4 or IPv6 Co-authored-by: TheLarkInn <3408176+TheLarkInn@users.noreply.github.com> * Rename address variable to formattedAddress for clarity Co-authored-by: TheLarkInn <3408176+TheLarkInn@users.noreply.github.com> * Add null check and handle both string and number IPv6 family values Co-authored-by: TheLarkInn <3408176+TheLarkInn@users.noreply.github.com> * Import AddressInfo from node:net and fix IPv6 family check Co-authored-by: TheLarkInn <3408176+TheLarkInn@users.noreply.github.com> * Improve type safety for server.address() return value Co-authored-by: TheLarkInn <3408176+TheLarkInn@users.noreply.github.com> * Extract formatAddress helper and improve error messages Co-authored-by: TheLarkInn <3408176+TheLarkInn@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: TheLarkInn <3408176+TheLarkInn@users.noreply.github.com>
…m/microsoft/rushstack into bmiddha/playwright-browser-server
…ll for browser server proxy
Summary
Introducing Playwright Browser Server. A CLI based tool to launch a remote browser provider for Playwright.
This tool enables using headful browsers on the local machine when using Playwright with VS Code remote sessions.
Use cases:
Details
This tool uses a reverse port forwarder concept to tunnel the Playwright WebSocket control messages over VS Code port forwarding.
Flow:
Playwright MCP can also be used through this setup in VS Code remote environments.
sequenceDiagram participant PT as Playwright Tests participant BF as Browser Fixture participant TS as Tunnel Server (WebSocket) participant HS as HTTP Server participant VSC as VS Code Extension participant BS as Browser Server participant LB as Local Browser Note over PT,LB: Context: Enables local browser testing for remote VS Code environments (e.g., Codespaces) PT->>BF: Trigger custom browser fixture par Fixture Setup BF->>HS: Launch localhost HTTP server BF->>TS: Launch WebSocket tunnel server (well-known port) end BF->>HS: browser.connect('http://localhost:<port>? browser=chromium&launchOptions={}') loop Polling VSC->>TS: Poll for connection (well-known port) end TS-->>VSC: WebSocket connection established BF->>VSC: Send handshake (browser type, launchOptions, Playwright version) VSC->>VSC: Install requested Playwright version VSC->>VSC: Install requested browser VSC->>BS: Launch browserServer via Playwright API BS->>LB: Start local browser instance VSC->>BS: Create WebSocket client connection VSC->>TS: Send acknowledgement (ready to go) par Setup Forwarding Note over BF,TS: Fixture: PT ↔ Tunnel Server Note over VSC,BS: Extension: Tunnel Server ↔ Browser Server end BF->>BF: Flush buffered messages from test rect rgb(200, 230, 200) Note over PT,LB: Transparent bidirectional communication established PT->>BF: Playwright commands BF->>TS: Forward to tunnel TS->>VSC: Forward to extension VSC->>BS: Forward to browser server BS->>LB: Execute in local browser LB-->>BS: Response BS-->>VSC: Forward response VSC-->>TS: Forward to tunnel TS-->>BF: Forward to fixture BF-->>PT: Return to test end Note over PT,LB: 🎉 Profit! Local browser available to remote tests transparentlyHow it was tested
Tested end-to-end with the Playwright test and fixture introduced in this change.
Tested this on pure local setup as well as on Codespaces
Tested MCP change by prompting agent mode to use Playwright MCP on Codespaces.