diff --git a/src/webkit/wkExecutionContext.ts b/src/webkit/wkExecutionContext.ts index 1e843cb842..547e22e6bd 100644 --- a/src/webkit/wkExecutionContext.ts +++ b/src/webkit/wkExecutionContext.ts @@ -219,9 +219,9 @@ export class WKExecutionContext implements js.ExecutionContextDelegate { } private _returnObjectByValue(objectId: Protocol.Runtime.RemoteObjectId) { - const serializeFunction = function(stringify: (o: any) => string) { + const serializeFunction = function() { try { - return stringify(this); + return JSON.stringify(this); } catch (e) { if (e instanceof TypeError) return void 0; @@ -232,7 +232,6 @@ export class WKExecutionContext implements js.ExecutionContextDelegate { // Serialize object using standard JSON implementation to correctly pass 'undefined'. functionDeclaration: serializeFunction + '\n' + suffix + '\n', objectId: objectId, - arguments: [ { objectId: this._jsonStringifyObjectId } ], returnByValue: true }).catch(e => { if (isSwappedOutError(e)) diff --git a/src/webkit/wkPage.ts b/src/webkit/wkPage.ts index adb737d74b..a413697190 100644 --- a/src/webkit/wkPage.ts +++ b/src/webkit/wkPage.ts @@ -37,8 +37,6 @@ import { getAccessibilityTree } from './wkAccessibility'; const UTILITY_WORLD_NAME = '__playwright_utility_world__'; const BINDING_CALL_MESSAGE = '__playwright_binding_call__'; -const JSON_CALL_MESSAGE = '__playwright_json_call__'; -const JSON_SAVE_SCRIPT = `console.debug('${JSON_CALL_MESSAGE}', JSON.stringify.bind(JSON))`; export class WKPage implements PageDelegate { readonly rawMouse: RawMouseImpl; @@ -50,7 +48,7 @@ export class WKPage implements PageDelegate { private readonly _contextIdToContext: Map; private _isolatedWorlds: Set; private _sessionListeners: RegisteredListener[] = []; - private readonly _bootstrapScripts: string[] = [ JSON_SAVE_SCRIPT ]; + private readonly _bootstrapScripts: string[] = []; constructor(browser: WKBrowser, browserContext: BrowserContext) { this._browser = browser; @@ -111,7 +109,6 @@ export class WKPage implements PageDelegate { if (this._page._state.viewport) promises.push(WKPage._setViewport(session, this._page._state.viewport)); await Promise.all(promises); - await this._page.evaluate(JSON_SAVE_SCRIPT); } didClose(crashed: boolean) { @@ -224,12 +221,6 @@ export class WKPage implements PageDelegate { this._page._onBindingCalled(parameters[2].value, context); return; } - if (level === 'debug' && parameters && parameters[0].value === JSON_CALL_MESSAGE) { - const parsedObjectId = JSON.parse(parameters[1].objectId); - const context = this._contextIdToContext.get(parsedObjectId.injectedScriptId); - (context._delegate as WKExecutionContext)._jsonStringifyObjectId = parameters[1].objectId; - return; - } if (level === 'error' && source === 'javascript') { const error = new Error(text); error.stack = ''; diff --git a/test/evaluation.spec.js b/test/evaluation.spec.js index 7fd2730575..6cf803f756 100644 --- a/test/evaluation.spec.js +++ b/test/evaluation.spec.js @@ -259,7 +259,7 @@ module.exports.describe = function({testRunner, expect, FFOX, CHROME, WEBKIT}) { })).catch(e => error = e); expect(error.message).toContain('Error in promise'); }); - it('should work even when JSON is set to null', async ({ page }) => { + it.skip(WEBKIT)('should work even when JSON is set to null', async ({ page }) => { await page.evaluate(() => { window.JSON.stringify = null; window.JSON = null; }); const result = await page.evaluate(() => ({abc: 123})); expect(result).toEqual({abc: 123});