Skip to content

Commit

Permalink
Streams: reject pending reads when releasing reader
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiasBuelens authored Jan 13, 2022
1 parent 04cbcb8 commit 99d74f9
Show file tree
Hide file tree
Showing 6 changed files with 578 additions and 45 deletions.
32 changes: 32 additions & 0 deletions streams/readable-byte-streams/bad-buffers-and-views.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,38 @@ async_test(t => {
}, 'ReadableStream with byte source: respondWithNewView() throws if the supplied view is zero-length on a ' +
'non-zero-length buffer (in the readable state)');

async_test(t => {
const stream = new ReadableStream({
pull: t.step_func_done(c => {
const view = c.byobRequest.view.subarray(1, 2);

assert_throws_js(RangeError, () => c.byobRequest.respondWithNewView(view));
}),
type: 'bytes'
});
const reader = stream.getReader({ mode: 'byob' });

reader.read(new Uint8Array([4, 5, 6]));
}, 'ReadableStream with byte source: respondWithNewView() throws if the supplied view has a different offset ' +
'(in the readable state)');

async_test(t => {
const stream = new ReadableStream({
pull: t.step_func_done(c => {
c.close();

const view = c.byobRequest.view.subarray(1, 1);

assert_throws_js(RangeError, () => c.byobRequest.respondWithNewView(view));
}),
type: 'bytes'
});
const reader = stream.getReader({ mode: 'byob' });

reader.read(new Uint8Array([4, 5, 6]));
}, 'ReadableStream with byte source: respondWithNewView() throws if the supplied view has a different offset ' +
'(in the closed state)');

async_test(t => {
const stream = new ReadableStream({
pull: t.step_func_done(c => {
Expand Down
Loading

0 comments on commit 99d74f9

Please sign in to comment.