test: add failing test for eval with overridden Array.toJSON (#6766)
This commit is contained in:
parent
fb3c6e50d4
commit
3b220e50ee
|
|
@ -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: {} });
|
||||
|
|
|
|||
Loading…
Reference in a new issue