Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(mcp): guard toWellFormed() for Node 18 compatibility (#39674)

Pavel Feldman47caab240330
diff --git a/packages/playwright-core/src/tools/backend/response.ts b/packages/playwright-core/src/tools/backend/response.ts
index 578c142d63..d686353c66 100644
--- a/packages/playwright-core/src/tools/backend/response.ts
+++ b/packages/playwright-core/src/tools/backend/response.ts
@@ -276,7 +276,9 @@ function trimMiddle(text: string, maxLength: number) {
* Replaces lone surrogates with U+FFFD using String.prototype.toWellFormed().
*/
function sanitizeUnicode(text: string): string {
- return text.toWellFormed();
+ if ((String.prototype as any).toWellFormed)
+ return text.toWellFormed();
+ return text;
}
function parseSections(text: string): Map<string, string> {