test: toJSON property for Arrays after evaluation in FF (#7016)

This commit is contained in:
Max Schmitt 2021-06-10 10:53:30 -07:00 committed by GitHub
parent 13b6d0153d
commit 5157f74bcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: {} });