allow-resizable.html (1149B)
1 <!DOCTYPE html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="/common/sab.js"></script> 5 <script type="module"> 6 test(t => { 7 // Fixed-length ABs should not throw 8 const ab = new ArrayBuffer(16); 9 new Response(new Uint8Array(ab)); 10 11 const rab = new ArrayBuffer(16, { maxByteLength: 1024 }); 12 // Response doesn't have [AllowResizable] or [AllowShared] 13 assert_throws_js(TypeError, () => { 14 new Response(new Uint8Array(rab)); 15 }); 16 }, "APIs without [AllowResizable] throw when passed resizable ArrayBuffers"); 17 18 test(t => { 19 const enc = new TextEncoder(); 20 21 // Fixed-length SABs should not throw 22 const sab = createBuffer('SharedArrayBuffer', 16); 23 enc.encodeInto("foobar", new Uint8Array(sab)); 24 25 const gsab = createBuffer('SharedArrayBuffer', 16, { maxByteLength: 1024 }); 26 // TextEncoder.encodeInto doesn't have [AllowResizable] but has [AllowShared] 27 assert_throws_js(TypeError, () => { 28 enc.encodeInto("foobar", new Uint8Array(gsab)); 29 }); 30 }, "APIs with [AllowShared] but without [AllowResizable] throw when passed growable SharedArrayBuffers"); 31 </script>