Skip to content

Commit a21ea3f

Browse files
committed
đź‘· update pinned proxy translation for Playwright 1.59
- Refresh comments to reference 1.59 client and v1.59.1 protocol diff. - Translate Browser initializer: populate `browserName` from legacy `name` field, which 1.59 now requires on BrowserInitializer.
1 parent 9265ec7 commit a21ea3f

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

‎test/e2e/scripts/pinnedProxy.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
// WebSocket translation proxy that lets a recent @playwright/test client (1.58) drive an
1+
// WebSocket translation proxy that lets a recent @playwright/test client (1.59) drive an
22
// older `playwright run-server` (1.40). Two layers of translation:
33
//
44
// 1) HTTP upgrade — the 1.40 server's User-Agent version check rejects mismatched clients
55
// with HTTP 428. We rewrite the upgrade request's User-Agent so the check passes.
66
//
7-
// 2) JSON-RPC — once connected, the 1.58 client validates server messages strictly and
8-
// sends commands using the 1.58 schema. We patch __create__ initializers (server→client)
7+
// 2) JSON-RPC — once connected, the recent client validates server messages strictly and
8+
// sends commands using the recent schema. We patch __create__ initializers (server→client)
99
// and command parameters (client→server) where the schemas diverge between versions.
1010
//
1111
// Patches were derived from a diff of packages/protocol/src/protocol.yml between v1.40.1
12-
// and v1.58.2 — only the divergences exercised by this repo's e2e tests are translated.
12+
// and v1.59.1 — only the divergences exercised by this repo's e2e tests are translated.
1313
//
1414
// Usage: node pinnedProxy.ts --listen 5400 --upstream 127.0.0.1:5401
1515

@@ -171,6 +171,11 @@ function rewriteServerToClient(text: string, guidTypes: Map<string, string>): st
171171
if (type === 'Request' && init.hasResponse === undefined) {
172172
init.hasResponse = false
173173
}
174+
// BrowserInitializer requires `browserName` in 1.59. In 1.40 the `name` field already
175+
// held the browser type ("chromium" | "firefox" | "webkit"), so copy it over.
176+
if (type === 'Browser' && init.browserName === undefined && typeof init.name === 'string') {
177+
init.browserName = init.name
178+
}
174179
msg.params.initializer = init
175180
}
176181
return JSON.stringify(msg)

0 commit comments

Comments
 (0)