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: add tests for ReadableStreamBYOBReader.read(view, { min }) #29723

Merged
merged 25 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
94e6a93
Remove unused test utils
MattiasBuelens Jul 19, 2021
44c4169
Inline methodRejects helper
MattiasBuelens Jul 19, 2021
cd3e7c9
Add tests for readFully()
MattiasBuelens Jul 19, 2021
d9aa223
More tests
MattiasBuelens Jul 22, 2021
8ab7ac8
Add a tricky test with 3 byte enqueue into 2 element Uint16Array
MattiasBuelens Jul 22, 2021
ba6d376
Test using readFully() on a tee'd branch
MattiasBuelens Aug 1, 2021
53c7844
Rename readFully() to fill()
MattiasBuelens Aug 19, 2021
e7909e2
Remove unused `controller` captures
MattiasBuelens Aug 19, 2021
19237c4
Rename
MattiasBuelens Aug 19, 2021
048f33b
Add missing assert descriptions
MattiasBuelens Aug 19, 2021
08db30e
Test whether fill() rejects when given a non-transferable buffer
MattiasBuelens Aug 19, 2021
f292df2
Test whether fill() resolves immediately for a closed stream
MattiasBuelens Aug 19, 2021
87607b3
Test whether close() fails when pending fill() is not yet sufficientl…
MattiasBuelens Aug 19, 2021
4315f72
Replace fill(view) with read(view, { atLeast })
MattiasBuelens Oct 14, 2021
067a0d0
Rename file
MattiasBuelens Jan 18, 2022
3deedde
Rename tests
MattiasBuelens Jan 18, 2022
2363a15
Test whether read(view) rejects if atLeast is 0
MattiasBuelens Apr 12, 2022
2e6cb14
Test whether read(view) rejects if atLeast is larger than view's length
MattiasBuelens Apr 12, 2022
7f9d885
Rename atLeast to min
MattiasBuelens Apr 28, 2022
07fc5ee
Rename file
MattiasBuelens Apr 28, 2022
c74b574
Test whether filling between min and view.length works
MattiasBuelens Apr 28, 2022
e9fb817
Test with a DataView
MattiasBuelens Apr 28, 2022
979fc6b
Test whether read(view) rejects if min is negative
MattiasBuelens Sep 16, 2023
88bc15c
Merge branch 'master' into rs-byob-read-fully
MattiasBuelens Sep 30, 2023
b510d99
Enable shadowrealm testing
MattiasBuelens Sep 30, 2023
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
7 changes: 4 additions & 3 deletions streams/piping/general.any.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// META: global=window,worker,shadowrealm
// META: script=../resources/test-utils.js
// META: script=../resources/recording-streams.js
'use strict';

Expand Down Expand Up @@ -39,7 +38,8 @@ promise_test(t => {
const fakeRS = Object.create(ReadableStream.prototype);
const ws = new WritableStream();

return methodRejects(t, ReadableStream.prototype, 'pipeTo', fakeRS, [ws]);
return promise_rejects_js(t, TypeError, ReadableStream.prototype.pipeTo.apply(fakeRS, [ws]),
'pipeTo should reject with a TypeError');
MattiasBuelens marked this conversation as resolved.
Show resolved Hide resolved

}, 'pipeTo must check the brand of its ReadableStream this value');

Expand All @@ -48,7 +48,8 @@ promise_test(t => {
const rs = new ReadableStream();
const fakeWS = Object.create(WritableStream.prototype);

return methodRejects(t, ReadableStream.prototype, 'pipeTo', rs, [fakeWS]);
return promise_rejects_js(t, TypeError, ReadableStream.prototype.pipeTo.apply(rs, [fakeWS]),
'pipeTo should reject with a TypeError');

}, 'pipeTo must check the brand of its WritableStream argument');

Expand Down
12 changes: 12 additions & 0 deletions streams/readable-byte-streams/non-transferable-buffers.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ promise_test(async t => {
await promise_rejects_js(t, TypeError, reader.read(view));
}, 'ReadableStream with byte source: read() with a non-transferable buffer');

promise_test(async t => {
const rs = new ReadableStream({
pull: t.unreached_func('pull() should not be called'),
type: 'bytes'
});

const reader = rs.getReader({ mode: 'byob' });
const memory = new WebAssembly.Memory({ initial: 1 });
const view = new Uint8Array(memory.buffer, 0, 1);
await promise_rejects_js(t, TypeError, reader.fill(view));
}, 'ReadableStream with byte source: fill() with a non-transferable buffer');

test(t => {
let controller;
const rs = new ReadableStream({
Expand Down
Loading