Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
feat(evaluate): survive null JSON (#351)
Pavel Feldmanb64bd35c2396
diff --git a/browser_patches/firefox/BUILD_NUMBER b/browser_patches/firefox/BUILD_NUMBERindex 617ba1c154..6cb3869343 100644--- a/browser_patches/firefox/BUILD_NUMBER+++ b/browser_patches/firefox/BUILD_NUMBER@@ -1 +1 @@-1008+1009diff --git a/browser_patches/firefox/patches/bootstrap.diff b/browser_patches/firefox/patches/bootstrap.diffindex 65715fa270..c43e000963 100644--- a/browser_patches/firefox/patches/bootstrap.diff+++ b/browser_patches/firefox/patches/bootstrap.diff@@ -2448,10 +2448,10 @@ index 0000000000000000000000000000000000000000..0031ff4cad5d479db52122f69c1cb6b0+diff --git a/testing/juggler/content/RuntimeAgent.js b/testing/juggler/content/RuntimeAgent.jsnew file mode 100644-index 0000000000000000000000000000000000000000..a8f017a071334c73aa96160c96018e6f5ac65d1f+index 0000000000000000000000000000000000000000..b43df14b060682711a59221f67fd2c3bba3a0f62--- /dev/null+++ b/testing/juggler/content/RuntimeAgent.js-@@ -0,0 +1,468 @@+@@ -0,0 +1,466 @@+"use strict";+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");+const {Helper} = ChromeUtils.import('chrome://juggler/content/Helper.js');@@ -2677,7 +2677,6 @@ index 0000000000000000000000000000000000000000..a8f017a071334c73aa96160c96018e6f+ let result = await executionContext.evaluateScript(expression, exceptionDetails);+ if (!result)+ return {exceptionDetails};-+ let isNode = undefined;+ if (returnByValue)+ result = executionContext.ensureSerializedToValue(result);+ return {result};@@ -2691,7 +2690,6 @@ index 0000000000000000000000000000000000000000..a8f017a071334c73aa96160c96018e6f+ let result = await executionContext.evaluateFunction(functionDeclaration, args, exceptionDetails);+ if (!result)+ return {exceptionDetails};-+ let isNode = undefined;+ if (returnByValue)+ result = executionContext.ensureSerializedToValue(result);+ return {result};@@ -2720,6 +2718,7 @@ index 0000000000000000000000000000000000000000..a8f017a071334c73aa96160c96018e6f+ this._remoteObjects = new Map();+ this._id = helper.generateId();+ this._auxData = auxData;++ this._jsonStringifyObject = this._global.executeInGlobal('JSON.stringify.bind(JSON)').return;+ }++ id() {@@ -2824,7 +2823,6 @@ index 0000000000000000000000000000000000000000..a8f017a071334c73aa96160c96018e6f+ (rawObj instanceof this._domWindow.Float64Array)) {+ subtype = 'typedarray';+ }-+ const isNode = debuggerObj.unsafeDereference() instanceof this._domWindow.Node;+ return {objectId, type, subtype};+ }+ if (typeof debuggerObj === 'symbol') {@@ -2871,7 +2869,7 @@ index 0000000000000000000000000000000000000000..a8f017a071334c73aa96160c96018e6f+ }++ _serialize(obj) {-+ const result = this._global.executeInGlobalWithBindings('JSON.stringify(e)', {e: obj});++ const result = this._global.executeInGlobalWithBindings('stringify(e)', {e: obj, stringify: this._jsonStringifyObject});+ if (result.throw)+ throw new Error('Object is not serializable');+ return JSON.parse(result.return);diff --git a/test/evaluation.spec.js b/test/evaluation.spec.jsindex c149dd93e6..8859f6ce95 100644--- a/test/evaluation.spec.js+++ b/test/evaluation.spec.js@@ -260,7 +260,7 @@ module.exports.describe = function({testRunner, expect, FFOX, CHROME, WEBKIT}) {expect(error.message).toContain('Error in promise');});it.skip(FFOX || WEBKIT)('should work even when JSON is set to null', async({page, server}) => {- await page.evaluate(() => window.JSON = null);+ await page.evaluate(() => { window.JSON.stringify = null; window.JSON = null; });const result = await page.evaluate(() => ({abc: 123}));expect(result).toEqual({abc: 123});})