Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
feat(driver): add option to strip out lone surrogates (#29179)
Max Schmitt4df4054f19c1
diff --git a/packages/playwright-core/src/cli/driver.ts b/packages/playwright-core/src/cli/driver.tsindex 245c733483..189ec4d2f6 100644--- a/packages/playwright-core/src/cli/driver.ts+++ b/packages/playwright-core/src/cli/driver.ts@@ -38,7 +38,15 @@ export function runDriver() {});const transport = new PipeTransport(process.stdout, process.stdin);transport.onmessage = (message: string) => dispatcherConnection.dispatch(JSON.parse(message));- dispatcherConnection.onmessage = message => transport.send(JSON.stringify(message));+ // Certain Language Binding JSON parsers (e.g. .NET) do not like strings with lone surrogates.+ const isJavaScriptLanguageBinding = !process.env.PW_LANG_NAME || process.env.PW_LANG_NAME === 'javascript';+ const replacer = !isJavaScriptLanguageBinding && (String.prototype as any).toWellFormed ? (key: string, value: any): any => {+ if (typeof value === 'string')+ // @ts-expect-error+ return value.toWellFormed();+ return value;+ } : undefined;+ dispatcherConnection.onmessage = message => transport.send(JSON.stringify(message, replacer));transport.onclose = () => {// Drop any messages during shutdown on the floor.dispatcherConnection.onmessage = () => {};