Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streams: reject pending reads when releasing reader #32072

Merged
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)');
Comment on lines +218 to +219
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive-by fix: I noticed that this check was not covered by any tests, so I added one. 🙂


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