@@ -84,6 +84,16 @@ test('BufferSource rejects SAB-backed DataView', () => {
8484 ) ;
8585} ) ;
8686
87+ test ( 'BufferSource rejects SAB view whose buffer prototype was reassigned' , ( ) => {
88+ const sab = new SharedArrayBuffer ( 4 ) ;
89+ Object . setPrototypeOf ( sab , ArrayBuffer . prototype ) ;
90+ const view = new Uint8Array ( sab ) ;
91+ assert . throws (
92+ ( ) => converters . BufferSource ( view ) ,
93+ { code : 'ERR_INVALID_ARG_TYPE' } ,
94+ ) ;
95+ } ) ;
96+
8797test ( 'BufferSource accepts a detached ArrayBuffer' , ( ) => {
8898 const ab = new ArrayBuffer ( 8 ) ;
8999 structuredClone ( ab , { transfer : [ ab ] } ) ;
@@ -169,6 +179,16 @@ test('ArrayBufferView rejects SAB-backed DataView', () => {
169179 ) ;
170180} ) ;
171181
182+ test ( 'ArrayBufferView rejects SAB view whose buffer prototype was reassigned' , ( ) => {
183+ const sab = new SharedArrayBuffer ( 4 ) ;
184+ Object . setPrototypeOf ( sab , ArrayBuffer . prototype ) ;
185+ const view = new Uint8Array ( sab ) ;
186+ assert . throws (
187+ ( ) => converters . ArrayBufferView ( view ) ,
188+ { code : 'ERR_INVALID_ARG_TYPE' } ,
189+ ) ;
190+ } ) ;
191+
172192test ( 'ArrayBufferView rejects objects with a forged @@toStringTag' , ( ) => {
173193 const fake = { [ Symbol . toStringTag ] : 'Uint8Array' } ;
174194 assert . throws (
0 commit comments