|
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 |
2 | 2 | // older `playwright run-server` (1.40). Two layers of translation: |
3 | 3 | // |
4 | 4 | // 1) HTTP upgrade — the 1.40 server's User-Agent version check rejects mismatched clients |
5 | 5 | // with HTTP 428. We rewrite the upgrade request's User-Agent so the check passes. |
6 | 6 | // |
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) |
9 | 9 | // and command parameters (client→server) where the schemas diverge between versions. |
10 | 10 | // |
11 | 11 | // 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. |
13 | 13 | // |
14 | 14 | // Usage: node pinnedProxy.ts --listen 5400 --upstream 127.0.0.1:5401 |
15 | 15 |
|
@@ -171,6 +171,11 @@ function rewriteServerToClient(text: string, guidTypes: Map<string, string>): st |
171 | 171 | if (type === 'Request' && init.hasResponse === undefined) { |
172 | 172 | init.hasResponse = false |
173 | 173 | } |
| 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 | + } |
174 | 179 | msg.params.initializer = init |
175 | 180 | } |
176 | 181 | return JSON.stringify(msg) |
|
0 commit comments