feat(executioncontext): support bigints transferring (#4016)

Refs: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#type-UnserializableValue
This commit is contained in:
Vse Mozhet Byt
2019-03-15 19:20:48 +02:00
committed by Andrey Lushnikov
parent 27cf8594c2
commit 854b1c0912
5 changed files with 20 additions and 4 deletions

View File

@@ -127,6 +127,8 @@ class ExecutionContext {
* @this {ExecutionContext}
*/
function convertArgument(arg) {
if (typeof arg === 'bigint') // eslint-disable-line valid-typeof
return { unserializableValue: `${arg.toString()}n` };
if (Object.is(arg, -0))
return { unserializableValue: '-0' };
if (Object.is(arg, Infinity))

View File

@@ -66,6 +66,8 @@ class Helper {
static valueFromRemoteObject(remoteObject) {
assert(!remoteObject.objectId, 'Cannot extract value when objectId is given');
if (remoteObject.unserializableValue) {
if (remoteObject.type === 'bigint' && typeof BigInt !== 'undefined')
return BigInt(remoteObject.unserializableValue.replace('n', ''));
switch (remoteObject.unserializableValue) {
case '-0':
return -0;