diff --git a/tests/page/page-evaluate.spec.ts b/tests/page/page-evaluate.spec.ts index c5e41cfae7..9b575d001c 100644 --- a/tests/page/page-evaluate.spec.ts +++ b/tests/page/page-evaluate.spec.ts @@ -548,7 +548,7 @@ 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('should not use Array.prototype.toJSON when evaluating', async ({ page }) => { const result = await page.evaluate(() => { (Array.prototype as any).toJSON = () => 'busted'; return [1, 2, 3]; @@ -556,6 +556,13 @@ it('should not use Array.prototype.toJSON when evaluating', async ({ page, brows expect(result).toEqual([1,2,3]); }); +it('should not add a toJSON property to newly created Arrays after evaluation', async ({ page, browserName }) => { + it.fixme(browserName === 'firefox') + await page.evaluate(() => []); + const hasToJSONProperty = await page.evaluate(() => "toJSON" in []); + expect(hasToJSONProperty).toEqual(false); +}); + 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: {} });