@@ -8,12 +8,12 @@ assert.throws(() => structuredClone(undefined, ''), { code: 'ERR_INVALID_ARG_TYP
88assert . throws ( ( ) => structuredClone ( undefined , 1 ) , { code : 'ERR_INVALID_ARG_TYPE' } ) ;
99assert . throws ( ( ) => structuredClone ( undefined , { transfer : 1 } ) , { code : 'ERR_INVALID_ARG_TYPE' } ) ;
1010assert . throws ( ( ) => structuredClone ( undefined , { transfer : '' } ) , { code : 'ERR_INVALID_ARG_TYPE' } ) ;
11+ assert . throws ( ( ) => structuredClone ( undefined , { transfer : null } ) , { code : 'ERR_INVALID_ARG_TYPE' } ) ;
1112
1213// Options can be null or undefined.
1314assert . strictEqual ( structuredClone ( undefined ) , undefined ) ;
1415assert . strictEqual ( structuredClone ( undefined , null ) , undefined ) ;
1516// Transfer can be null or undefined.
16- assert . strictEqual ( structuredClone ( undefined , { transfer : null } ) , undefined ) ;
1717assert . strictEqual ( structuredClone ( undefined , { } ) , undefined ) ;
1818
1919// Transferables or its subclasses should be received with its closest transferable superclass
@@ -43,6 +43,27 @@ for (const Transferrable of [File, Blob]) {
4343 assert . ok ( extendedTransfer instanceof Transferrable ) ;
4444}
4545
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+
4667{
4768 // See: https://github.com/nodejs/node/issues/49940
4869 const cloned = structuredClone ( { } , {
0 commit comments