diff --git a/tests/page/page-evaluate.spec.ts b/tests/page/page-evaluate.spec.ts index 942ef5308e..842621c8e8 100644 --- a/tests/page/page-evaluate.spec.ts +++ b/tests/page/page-evaluate.spec.ts @@ -550,6 +550,15 @@ it('should not use toJSON when evaluating', async ({ page }) => { expect(result).toEqual({ data: 'data', toJSON: {} }); }); +it('should not use Array.prototype.toJSON when evaluating', async ({ page, browserName }) => { + it.fixme(browserName === 'firefox', 'https://github.com/microsoft/playwright/issues/6750'); + const result = await page.evaluate(() => { + (Array.prototype as any).toJSON = () => 'busted'; + return [1, 2, 3]; + }); + expect(result).toEqual([1,2,3]); +}); + it('should not use toJSON in jsonValue', async ({ page }) => { const resultHandle = await page.evaluateHandle(() => ({ toJSON: () => 'string', data: 'data' })); expect(await resultHandle.jsonValue()).toEqual({ data: 'data', toJSON: {} });