parent
c6a0f3e8a0
commit
b0b429fed0
|
|
@ -71,6 +71,8 @@ function innerParseSerializedValue(value: SerializedValue, handles: any[] | unde
|
|||
return new Date(value.d);
|
||||
if (value.u !== undefined)
|
||||
return new URL(value.u);
|
||||
if (value.bi !== undefined)
|
||||
return BigInt(value.bi);
|
||||
if (value.r !== undefined)
|
||||
return new RegExp(value.r.p, value.r.f);
|
||||
|
||||
|
|
@ -133,6 +135,8 @@ function innerSerializeValue(value: any, handleSerializer: (value: any) => Handl
|
|||
return { n: value };
|
||||
if (typeof value === 'string')
|
||||
return { s: value };
|
||||
if (typeof value === 'bigint')
|
||||
return { bi: value.toString() };
|
||||
if (isError(value)) {
|
||||
const error = value;
|
||||
if ('captureStackTrace' in globalThis.Error) {
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ scheme.SerializedValue = tObject({
|
|||
v: tOptional(tEnum(['null', 'undefined', 'NaN', 'Infinity', '-Infinity', '-0'])),
|
||||
d: tOptional(tString),
|
||||
u: tOptional(tString),
|
||||
bi: tOptional(tString),
|
||||
r: tOptional(tObject({
|
||||
p: tString,
|
||||
f: tString,
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ export type SerializedValue =
|
|||
{ v: 'null' | 'undefined' | 'NaN' | 'Infinity' | '-Infinity' | '-0' } |
|
||||
{ d: string } |
|
||||
{ u: string } |
|
||||
{ bi: string } |
|
||||
{ r: { p: string, f: string} } |
|
||||
{ a: SerializedValue[], id: number } |
|
||||
{ o: { k: string, v: SerializedValue }[], id: number } |
|
||||
|
|
@ -91,6 +92,8 @@ export function source() {
|
|||
return new Date(value.d);
|
||||
if ('u' in value)
|
||||
return new URL(value.u);
|
||||
if ('bi' in value)
|
||||
return BigInt(value.bi);
|
||||
if ('r' in value)
|
||||
return new RegExp(value.r.p, value.r.f);
|
||||
if ('a' in value) {
|
||||
|
|
@ -157,6 +160,8 @@ export function source() {
|
|||
return value;
|
||||
if (typeof value === 'string')
|
||||
return value;
|
||||
if (typeof value === 'bigint')
|
||||
return { bi: value.toString() };
|
||||
|
||||
if (isError(value)) {
|
||||
const error = value;
|
||||
|
|
|
|||
|
|
@ -179,6 +179,7 @@ export type SerializedValue = {
|
|||
v?: 'null' | 'undefined' | 'NaN' | 'Infinity' | '-Infinity' | '-0',
|
||||
d?: string,
|
||||
u?: string,
|
||||
bi?: string,
|
||||
r?: {
|
||||
p: string,
|
||||
f: string,
|
||||
|
|
|
|||
|
|
@ -80,6 +80,8 @@ SerializedValue:
|
|||
d: string?
|
||||
# String representation of the URL.
|
||||
u: string?
|
||||
# String representation of BigInt.
|
||||
bi: string?
|
||||
# Regular expression pattern and flags.
|
||||
r:
|
||||
type: object?
|
||||
|
|
|
|||
|
|
@ -94,6 +94,11 @@ it('should transfer arrays as arrays, not objects', async ({ page }) => {
|
|||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it('should transfer bigint', async ({ page }) => {
|
||||
expect(await page.evaluate(() => 42n)).toBe(42n);
|
||||
expect(await page.evaluate(a => a, 17n)).toBe(17n);
|
||||
});
|
||||
|
||||
it('should transfer maps as empty objects', async ({ page }) => {
|
||||
const result = await page.evaluate(a => a.x.constructor.name + ' ' + JSON.stringify(a.x), { x: new Map([[1, 2]]) });
|
||||
expect(result).toBe('Object {}');
|
||||
|
|
|
|||
Loading…
Reference in a new issue