mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
feat(executioncontext): support bigints transferring (#4016)
Refs: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#type-UnserializableValue
This commit is contained in:
committed by
Andrey Lushnikov
parent
27cf8594c2
commit
854b1c0912
@@ -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))
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user