Skip to content

feat(route): expose WebSocket subprotocols on WebSocketRoute#40377

Merged
dgozman merged 1 commit intomicrosoft:mainfrom
rohitpaulk:add-protocols-to-mock
Apr 23, 2026
Merged

feat(route): expose WebSocket subprotocols on WebSocketRoute#40377
dgozman merged 1 commit intomicrosoft:mainfrom
rohitpaulk:add-protocols-to-mock

Conversation

@rohitpaulk
Copy link
Copy Markdown
Contributor

@rohitpaulk rohitpaulk commented Apr 23, 2026

Fixes #40376

Adds WebSocketRoute.protocols(): string[] so route handlers can read the subprotocols the page passed to new WebSocket(url, protocols). This corresponds to the Sec-WebSocket-Protocol request header, which is the only handshake header value page-side JS actually sets.

@rohitpaulk
Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree


Returns an empty array if no protocols were specified.

**Usage**
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Wasn't sure if this should go here or at the top, doesn't look like the other methods have usage examples inline.

Adds `WebSocketRoute.protocols(): string[]` so route handlers can read
the subprotocols the page passed to `new WebSocket(url, protocols)`.
This corresponds to the `Sec-WebSocket-Protocol` request header, which
is the only handshake header value page-side JS actually originates.
@rohitpaulk rohitpaulk force-pushed the add-protocols-to-mock branch from e2d14c6 to 0b43b80 Compare April 23, 2026 11:25
@github-actions
Copy link
Copy Markdown
Contributor

Test results for "MCP"

4 failed
❌ [firefox] › mcp/cli-devtools.spec.ts:141 › video-start-stop @mcp-windows-latest
❌ [firefox] › mcp/cli-devtools.spec.ts:155 › video-chapter @mcp-windows-latest
❌ [webkit] › mcp/dashboard.spec.ts:229 › should switch screencast to -s session on show --annotate @mcp-ubuntu-latest
❌ [webkit] › mcp/dashboard.spec.ts:229 › should switch screencast to -s session on show --annotate @mcp-windows-latest

6581 passed, 916 skipped


Merge workflow run.

@github-actions
Copy link
Copy Markdown
Contributor

Test results for "tests 1"

14 flaky ⚠️ [chromium-library] › library/browser.spec.ts:73 › newContext should not leave a context upon failure `@ubuntu-22.04-chromium-tip-of-tree`
⚠️ [chromium-library] › library/browser.spec.ts:73 › newContext should not leave a context upon failure `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/browser.spec.ts:73 › newContext should not leave a context upon failure `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-library] › library/video.spec.ts:275 › screencast › should capture navigation `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-library] › library/browser.spec.ts:73 › newContext should not leave a context upon failure `@chromium-ubuntu-22.04-node20`
⚠️ [chromium-library] › library/video.spec.ts:719 › screencast › should work with video+trace `@chromium-ubuntu-22.04-node20`
⚠️ [chromium-library] › library/browser.spec.ts:73 › newContext should not leave a context upon failure `@chromium-ubuntu-22.04-node22`
⚠️ [chromium-library] › library/popup.spec.ts:261 › should not throw when click closes popup `@chromium-ubuntu-22.04-node22`
⚠️ [firefox-library] › library/browser.spec.ts:73 › newContext should not leave a context upon failure `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1080 › cli codegen › should not throw csp directive violation errors `@firefox-ubuntu-22.04-node20`
⚠️ [webkit-library] › library/browser.spec.ts:73 › newContext should not leave a context upon failure `@webkit-ubuntu-22.04-node20`
⚠️ [webkit-library] › library/browsertype-connect.spec.ts:776 › launchServer › should upload a folder `@webkit-ubuntu-22.04-node20`
⚠️ [playwright-test] › ui-mode-test-output.spec.ts:118 › should collapse repeated console messages for test `@ubuntu-latest-node20`
⚠️ [playwright-test] › ui-mode-trace.spec.ts:433 › should work behind reverse proxy `@windows-latest-node20`

41317 passed, 847 skipped


Merge workflow run.

Copy link
Copy Markdown
Collaborator

@dgozman dgozman left a comment

Choose a reason for hiding this comment

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

This looks great, thank you for the PR!

@rohitpaulk
Copy link
Copy Markdown
Contributor Author

Thanks for the quick merge @dgozman!

@rohitpaulk rohitpaulk deleted the add-protocols-to-mock branch April 23, 2026 19:25
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.

[Feature]: Access requested subprotocols when mocking websocket requests

2 participants