fix(webkit): returnByValue returns undefined for objects with symbols
This commit is contained in:
parent
32edca7395
commit
109b4f827e
|
|
@ -219,9 +219,15 @@ export class WKExecutionContext implements js.ExecutionContextDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
private _returnObjectByValue(objectId: Protocol.Runtime.RemoteObjectId) {
|
private _returnObjectByValue(objectId: Protocol.Runtime.RemoteObjectId) {
|
||||||
const serializeFunction = function(stringify: (o: any) => string) {
|
const serializeFunction = function(stringify: (o: any, replacer: (key: any, value: any) => any) => string) {
|
||||||
try {
|
try {
|
||||||
return stringify(this);
|
let hasSymbol = false;
|
||||||
|
const result = stringify(this, (key, value) => {
|
||||||
|
if (typeof value === 'symbol')
|
||||||
|
hasSymbol = true;
|
||||||
|
return value;
|
||||||
|
});
|
||||||
|
return hasSymbol ? undefined : result;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof TypeError)
|
if (e instanceof TypeError)
|
||||||
return void 0;
|
return void 0;
|
||||||
|
|
|
||||||
|
|
@ -61,8 +61,16 @@ module.exports.describe = function({testRunner, expect, FFOX, CHROME, WEBKIT}) {
|
||||||
await page.goto(server.PREFIX + '/global-var.html');
|
await page.goto(server.PREFIX + '/global-var.html');
|
||||||
expect(await page.evaluate('globalVar')).toBe(123);
|
expect(await page.evaluate('globalVar')).toBe(123);
|
||||||
});
|
});
|
||||||
it.skip(FFOX || WEBKIT)('should return undefined for objects with symbols', async({page, server}) => {
|
it.skip(FFOX)('should return undefined for objects with symbols', async({page, server}) => {
|
||||||
expect(await page.evaluate(() => [Symbol('foo4')])).toBe(undefined);
|
expect(await page.evaluate(() => [Symbol('foo4')])).toBe(undefined);
|
||||||
|
expect(await page.evaluate(() => {
|
||||||
|
const a = { };
|
||||||
|
a[Symbol('foo4')] = 42;
|
||||||
|
return a;
|
||||||
|
})).toEqual({});
|
||||||
|
expect(await page.evaluate(() => {
|
||||||
|
return { foo: [{ a: Symbol('foo4') }] };
|
||||||
|
})).toBe(undefined);
|
||||||
});
|
});
|
||||||
it('should work with function shorthands', async({page, server}) => {
|
it('should work with function shorthands', async({page, server}) => {
|
||||||
const a = {
|
const a = {
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ module.exports.describe = function({testRunner, expect, headless, playwright, FF
|
||||||
expect(await page.evaluate(() => !!window.opener)).toBe(false);
|
expect(await page.evaluate(() => !!window.opener)).toBe(false);
|
||||||
expect(await popup.evaluate(() => !!window.opener)).toBe(false);
|
expect(await popup.evaluate(() => !!window.opener)).toBe(false);
|
||||||
});
|
});
|
||||||
it.skip(WEBKIT || FFOX)('should not treat navigations as new popups', async({page, server}) => {
|
it('should not treat navigations as new popups', async({page, server}) => {
|
||||||
await page.goto(server.EMPTY_PAGE);
|
await page.goto(server.EMPTY_PAGE);
|
||||||
await page.setContent('<a target=_blank rel=noopener href="/one-style.html">yo</a>');
|
await page.setContent('<a target=_blank rel=noopener href="/one-style.html">yo</a>');
|
||||||
const [popup] = await Promise.all([
|
const [popup] = await Promise.all([
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue