Unverified Commit de2dac30 authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

test: escape HMR payloads in Playwright trace annotations

Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
parent 94ea1c21
...@@ -382,11 +382,13 @@ export class Playwright<TCurrent = undefined> { ...@@ -382,11 +382,13 @@ export class Playwright<TCurrent = undefined> {
if (tracePlaywright) { if (tracePlaywright) {
const { payload } = frame const { payload } = frame
const text =
typeof payload === 'string' ? payload : decoder!.decode(payload)
page page
// Note that passing the payload as a an argument is 2 orders of magnitude more expensive in Playwright. // Note that passing the payload as a an argument is 2 orders of magnitude more expensive in Playwright.
.evaluate( // Instead, serialize the whole message into a string literal expression so that
`'received ws message ${JSON.stringify(typeof payload === 'string' ? payload : decoder!.decode(payload))}'` // any quotes or backslashes in the payload are escaped.
) .evaluate(JSON.stringify(`received ws message ${text}`))
.catch(() => {}) .catch(() => {})
} }
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment