feat(evaluate): survive null JSON (#351)
This commit is contained in:
Родитель
6a04e1f026
Коммит
b64bd35c23
|
@ -1 +1 @@
|
||||||
1008
|
1009
|
||||||
|
|
|
@ -2448,10 +2448,10 @@ index 0000000000000000000000000000000000000000..0031ff4cad5d479db52122f69c1cb6b0
|
||||||
+
|
+
|
||||||
diff --git a/testing/juggler/content/RuntimeAgent.js b/testing/juggler/content/RuntimeAgent.js
|
diff --git a/testing/juggler/content/RuntimeAgent.js b/testing/juggler/content/RuntimeAgent.js
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..a8f017a071334c73aa96160c96018e6f5ac65d1f
|
index 0000000000000000000000000000000000000000..b43df14b060682711a59221f67fd2c3bba3a0f62
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/testing/juggler/content/RuntimeAgent.js
|
+++ b/testing/juggler/content/RuntimeAgent.js
|
||||||
@@ -0,0 +1,468 @@
|
@@ -0,0 +1,466 @@
|
||||||
+"use strict";
|
+"use strict";
|
||||||
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
+const {Helper} = ChromeUtils.import('chrome://juggler/content/Helper.js');
|
+const {Helper} = ChromeUtils.import('chrome://juggler/content/Helper.js');
|
||||||
|
@ -2677,7 +2677,6 @@ index 0000000000000000000000000000000000000000..a8f017a071334c73aa96160c96018e6f
|
||||||
+ let result = await executionContext.evaluateScript(expression, exceptionDetails);
|
+ let result = await executionContext.evaluateScript(expression, exceptionDetails);
|
||||||
+ if (!result)
|
+ if (!result)
|
||||||
+ return {exceptionDetails};
|
+ return {exceptionDetails};
|
||||||
+ let isNode = undefined;
|
|
||||||
+ if (returnByValue)
|
+ if (returnByValue)
|
||||||
+ result = executionContext.ensureSerializedToValue(result);
|
+ result = executionContext.ensureSerializedToValue(result);
|
||||||
+ return {result};
|
+ return {result};
|
||||||
|
@ -2691,7 +2690,6 @@ index 0000000000000000000000000000000000000000..a8f017a071334c73aa96160c96018e6f
|
||||||
+ let result = await executionContext.evaluateFunction(functionDeclaration, args, exceptionDetails);
|
+ let result = await executionContext.evaluateFunction(functionDeclaration, args, exceptionDetails);
|
||||||
+ if (!result)
|
+ if (!result)
|
||||||
+ return {exceptionDetails};
|
+ return {exceptionDetails};
|
||||||
+ let isNode = undefined;
|
|
||||||
+ if (returnByValue)
|
+ if (returnByValue)
|
||||||
+ result = executionContext.ensureSerializedToValue(result);
|
+ result = executionContext.ensureSerializedToValue(result);
|
||||||
+ return {result};
|
+ return {result};
|
||||||
|
@ -2720,6 +2718,7 @@ index 0000000000000000000000000000000000000000..a8f017a071334c73aa96160c96018e6f
|
||||||
+ this._remoteObjects = new Map();
|
+ this._remoteObjects = new Map();
|
||||||
+ this._id = helper.generateId();
|
+ this._id = helper.generateId();
|
||||||
+ this._auxData = auxData;
|
+ this._auxData = auxData;
|
||||||
|
+ this._jsonStringifyObject = this._global.executeInGlobal('JSON.stringify.bind(JSON)').return;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ id() {
|
+ id() {
|
||||||
|
@ -2824,7 +2823,6 @@ index 0000000000000000000000000000000000000000..a8f017a071334c73aa96160c96018e6f
|
||||||
+ (rawObj instanceof this._domWindow.Float64Array)) {
|
+ (rawObj instanceof this._domWindow.Float64Array)) {
|
||||||
+ subtype = 'typedarray';
|
+ subtype = 'typedarray';
|
||||||
+ }
|
+ }
|
||||||
+ const isNode = debuggerObj.unsafeDereference() instanceof this._domWindow.Node;
|
|
||||||
+ return {objectId, type, subtype};
|
+ return {objectId, type, subtype};
|
||||||
+ }
|
+ }
|
||||||
+ if (typeof debuggerObj === 'symbol') {
|
+ if (typeof debuggerObj === 'symbol') {
|
||||||
|
@ -2871,7 +2869,7 @@ index 0000000000000000000000000000000000000000..a8f017a071334c73aa96160c96018e6f
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ _serialize(obj) {
|
+ _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)
|
+ if (result.throw)
|
||||||
+ throw new Error('Object is not serializable');
|
+ throw new Error('Object is not serializable');
|
||||||
+ return JSON.parse(result.return);
|
+ return JSON.parse(result.return);
|
||||||
|
|
|
@ -260,7 +260,7 @@ module.exports.describe = function({testRunner, expect, FFOX, CHROME, WEBKIT}) {
|
||||||
expect(error.message).toContain('Error in promise');
|
expect(error.message).toContain('Error in promise');
|
||||||
});
|
});
|
||||||
it.skip(FFOX || WEBKIT)('should work even when JSON is set to null', async({page, server}) => {
|
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}));
|
const result = await page.evaluate(() => ({abc: 123}));
|
||||||
expect(result).toEqual({abc: 123});
|
expect(result).toEqual({abc: 123});
|
||||||
})
|
})
|
||||||
|
|
Загрузка…
Ссылка в новой задаче