@@ -8,12 +8,12 @@ assert.throws(() => structuredClone(undefined, ''), { code: 'ERR_INVALID_ARG_TYP
8
8
assert . throws ( ( ) => structuredClone ( undefined , 1 ) , { code : 'ERR_INVALID_ARG_TYPE' } ) ;
9
9
assert . throws ( ( ) => structuredClone ( undefined , { transfer : 1 } ) , { code : 'ERR_INVALID_ARG_TYPE' } ) ;
10
10
assert . throws ( ( ) => structuredClone ( undefined , { transfer : '' } ) , { code : 'ERR_INVALID_ARG_TYPE' } ) ;
11
+ assert . throws ( ( ) => structuredClone ( undefined , { transfer : null } ) , { code : 'ERR_INVALID_ARG_TYPE' } ) ;
11
12
12
13
// Options can be null or undefined.
13
14
assert . strictEqual ( structuredClone ( undefined ) , undefined ) ;
14
15
assert . strictEqual ( structuredClone ( undefined , null ) , undefined ) ;
15
16
// Transfer can be null or undefined.
16
- assert . strictEqual ( structuredClone ( undefined , { transfer : null } ) , undefined ) ;
17
17
assert . strictEqual ( structuredClone ( undefined , { } ) , undefined ) ;
18
18
19
19
// Transferables or its subclasses should be received with its closest transferable superclass
@@ -43,6 +43,27 @@ for (const Transferrable of [File, Blob]) {
43
43
assert . ok ( extendedTransfer instanceof Transferrable ) ;
44
44
}
45
45
46
+ // Transfer can be iterable
47
+ {
48
+ const value = {
49
+ a : new ReadableStream ( ) ,
50
+ b : new WritableStream ( ) ,
51
+ } ;
52
+ const cloned = structuredClone ( value , {
53
+ transfer : {
54
+ * [ Symbol . iterator ] ( ) {
55
+ for ( const key in value ) {
56
+ yield value [ key ] ;
57
+ }
58
+ }
59
+ }
60
+ } ) ;
61
+ for ( const key in value ) {
62
+ assert . ok ( value [ key ] . locked ) ;
63
+ assert . ok ( ! cloned [ key ] . locked ) ;
64
+ }
65
+ }
66
+
46
67
{
47
68
// See: https://github.com/nodejs/node/issues/49940
48
69
const cloned = structuredClone ( { } , {
0 commit comments