browser(firefox): fixed Array.prototype.toJSON workaround (#7018)

References #7015
This commit is contained in:
Max Schmitt 2021-06-10 17:21:20 -07:00 committed by GitHub
parent 3b1bae8a40
commit 9b9091b3fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 14 deletions

View File

@ -1,2 +1,2 @@
1262
Changed: max@schmitt.mx Tue Jun 8 21:07:04 UTC 2021
1263
Changed: max@schmitt.mx Thu Jun 10 14:40:52 UTC 2021

View File

@ -295,10 +295,12 @@ class ExecutionContext {
this._id = generateId();
this._auxData = auxData;
this._jsonStringifyObject = this._debuggee.executeInGlobal(`((stringify, object) => {
const oldToJson = Date.prototype.toJSON;
const oldToJSON = Date.prototype.toJSON;
Date.prototype.toJSON = undefined;
const oldArrayToJson = Array.prototype.toJSON;
Array.prototype.toJSON = undefined;
const oldArrayToJSON = Array.prototype.toJSON;
const oldArrayHadToJSON = Array.prototype.hasOwnProperty('toJSON');
if (oldArrayHadToJSON)
Array.prototype.toJSON = undefined;
let hasSymbol = false;
const result = stringify(object, (key, value) => {
@ -307,8 +309,9 @@ class ExecutionContext {
return value;
});
Date.prototype.toJSON = oldToJson;
Array.prototype.toJSON = oldArrayToJson;
Date.prototype.toJSON = oldToJSON;
if (oldArrayHadToJSON)
Array.prototype.toJSON = oldArrayToJSON;
return hasSymbol ? undefined : result;
}).bind(null, JSON.stringify.bind(JSON))`).return;

View File

@ -1,2 +1,2 @@
1270
Changed: max@schmitt.mx Tue Jun 8 20:11:01 UTC 2021
1271
Changed: max@schmitt.mx Thu Jun 10 14:39:06 UTC 2021

View File

@ -295,10 +295,12 @@ class ExecutionContext {
this._id = generateId();
this._auxData = auxData;
this._jsonStringifyObject = this._debuggee.executeInGlobal(`((stringify, object) => {
const oldToJson = Date.prototype.toJSON;
const oldToJSON = Date.prototype.toJSON;
Date.prototype.toJSON = undefined;
const oldArrayToJson = Array.prototype.toJSON;
Array.prototype.toJSON = undefined;
const oldArrayToJSON = Array.prototype.toJSON;
const oldArrayHadToJSON = Array.prototype.hasOwnProperty('toJSON');
if (oldArrayHadToJSON)
Array.prototype.toJSON = undefined;
let hasSymbol = false;
const result = stringify(object, (key, value) => {
@ -307,8 +309,9 @@ class ExecutionContext {
return value;
});
Date.prototype.toJSON = oldToJson;
Array.prototype.toJSON = oldArrayToJson;
Date.prototype.toJSON = oldToJSON;
if (oldArrayHadToJSON)
Array.prototype.toJSON = oldArrayToJSON;
return hasSymbol ? undefined : result;
}).bind(null, JSON.stringify.bind(JSON))`).return;