Debian Codegraph @

testing/web-platform/tests/streams/readable-byte-streams/enqueue-with-detached-buffer.any.js

raw
1 // META: global=window,worker,shadowrealm
2
3 promise_test(async t => {
4 const error = new Error('cannot proceed');
5 const rs = new ReadableStream({
6 type: 'bytes',
7 pull: t.step_func((controller) => {
8 const buffer = controller.byobRequest.view.buffer;
9 // Detach the buffer.
10 structuredClone(buffer, { transfer: [buffer] });
11
12 // Try to enqueue with a new buffer.
13 assert_throws_js(TypeError, () => controller.enqueue(new Uint8Array([42])));
14
15 // If we got here the test passed.
16 controller.error(error);
17 })
18 });
19 const reader = rs.getReader({ mode: 'byob' });
20 await promise_rejects_exactly(t, error, reader.read(new Uint8Array(1)));
21 }, 'enqueue after detaching byobRequest.view.buffer should throw');