[Bug]: Recorder/codegen and page bindings break when the page defines Array.prototype.toJSON
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 68/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- javascript, typescript
Línea de trabajo
Comienza con bindingsController.ts y la ruta de PageBinding.dispatch descrita en el informe; después, ejecuta la reproducción vinculada de repro.spec.ts tras instalar Chromium. Rastrea cómo el Array.prototype.toJSON de la página cambia la carga útil del binding y verifica que los clics del recorder se registren sin el error serializedArgs.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Version
1.61.0
Steps to reproduce
Recorder:
- Run
npx playwright codegenand navigate to any page (evenabout:blank). - In the browser's DevTools Console, paste the kind of serializer Prototype.js installs:
Array.prototype.toJSON = function () { var results = []; this.forEach(function (value) { results.push(typeof value === 'object' ? JSON.stringify(value) : String(value)); }); return '[' + results.join(', ') + ']'; }; - Click any element. Recording stops with the error below.
Deterministic (no UI): minimal repo https://github.com/whgksqls9999/pw-tojson-recorder-repro
git clone https://github.com/whgksqls9999/pw-tojson-recorder-repro
cd pw-tojson-recorder-repro
npm install
npx playwright install chromium
npx playwright test repro.spec.ts
Expected behavior
When an element is clicked, codegen tracks it and records the corresponding action.
Actual behavior
Error: serializedArgs is not an array. This can happen when Array.prototype.toJSON is defined incorrectly
at _PageBinding.dispatch
at _Page.onBindingCalled
at _FrameSession._onBindingCalled
The recorder is unusable on such a page.
Additional context
Root cause: the injected binding controller serializes its payload with the page's JSON.stringify, so a page-defined Array.prototype.toJSON turns the internal serializedArgs array into a string and PageBinding.dispatch rejects it.
I completely understand the decision in #32508 to surface a clear log rather than handle the error. The one thing I'd gently raise is the user experience: a developer whose app has such an incorrect Array.prototype.toJSON override might try codegen, see that clicks do nothing, and — without opening DevTools — assume "maybe this just doesn't fit our app" and move on. That's partly on the developer for not checking, of course, but it can be an easy silent dead end. Would you be open to revisiting this case, or do you feel the current approach is the one to keep?
As a heavily simplified illustration, something like the patch below worked in my testing. If you feel this direction is worth pursuing, I'd be glad to refine it as needed and take the work forward.
[bindingsController.ts]
private _stringifyPayload(payload: BindingPayload): string {
const arrayToJSON = Array.prototype.toJSON;
const objectToJSON = Object.prototype.toJSON;
try {
delete Array.prototype.toJSON;
delete Object.prototype.toJSON;
return JSON.stringify(payload);
} finally {
if (arrayToJSON !== undefined) Array.prototype.toJSON = arrayToJSON;
if (objectToJSON !== undefined) Object.prototype.toJSON = objectToJSON;
}
}
(this._global as any)[this._globalBindingName](
this._stringifyPayload(payload),
);
Environment
System:
OS: Windows 10 Home 10.0.19045
CPU: (16) x64 12th Gen Intel(R) Core(TM) i5-12500H
Memory: 1.54 GB / 15.71 GB
Binaries:
Node: 22.20.0
npm: 10.9.3
npmPackages:
@playwright/test: 1.61.0 => 1.61.0
- Lenguaje dominante
- TypeScript
- Estrellas
- 97.4k
- Forks
- 6.6k
- Merge medio
- 18 h 15 min
- PR fusionados (30 d)
- 318
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/playwright
-
[Feature]: Set `this.name` in `TargetClosedError` constructorQuizá libre de nuevo @LeonxLJX la tomó hace 43 días y no hay ningún pull request abierto. AbiertoP3-collecting-feedback
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
microsoft/playwright#42522 · 7 comentarios ·
Los mantenedores suelen responder en 1 día
-
[Bug]: ariaSnapshot() emits \uXXXX / \b escapes in role names that toMatchAriaSnapshot() parses back incorrectlyPosiblemente ocupada @alok-108 la tomó hoy. Abierto
Dificultad 3/5 Medio día Aptitud para principiantes 22/100
microsoft/playwright#43489 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: Chromium – locale is not applied to Accept-Language / navigator.languages inside dedicated WorkersPosiblemente ocupada @yury-s la tomó hoy. Abierto
Dificultad 3/5 Medio día Aptitud para principiantes 25/100
microsoft/playwright#43484 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: fill() on a paragraph inside a contenteditable body in an iframe resolves but inserts nothingPosiblemente ocupada @yury-s la tomó hoy. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 18/100
microsoft/playwright#43483 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: Python sync API logs CancelledError when exiting sync_playwright() with an unanswered routePosiblemente ocupada @yury-s la tomó hoy. Abierto
Dificultad 2/5 Menos de una hora Aptitud para principiantes 18/100
microsoft/playwright#43463 ·
Los mantenedores suelen responder en 1 día
Todos los issues de microsoft/playwright
Issues similares
-
bug engine
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
frostney/GocciaScript#1746 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
agilepathway/label-checker#739 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
-
Wrong key location at startupAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
CopilotKit/OpenBot#800 ·
Los mantenedores suelen responder en 1 día
-
Endpoint links in the tag operations list are below the 24px target sizePosiblemente ocupada @AdzerKI la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
ehmpathy/rhachet-roles-bhuild#471 ·
Los mantenedores suelen responder en 1 día