Skip to content

Commit

Permalink
Bug 1721499 [wpt PR 29723] - Streams: add tests for ReadableStreamBYO…
Browse files Browse the repository at this point in the history
…BReader.read(view, { min }), a=testonly

Automatic update from web-platform-tests
Streams: add tests for ReadableStreamBYOBReader read(view, { min })

Follows whatwg/streams#1145.
--

wpt-commits: 7eaf605c38d80377c717828376deabad86b702b2
wpt-pr: 29723
  • Loading branch information
MattiasBuelens authored and moz-wptsync-bot committed Nov 22, 2023
1 parent 693ae24 commit f7958a6
Show file tree
Hide file tree
Showing 4 changed files with 790 additions and 50 deletions.
7 changes: 4 additions & 3 deletions testing/web-platform/tests/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');

}, '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
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

0 comments on commit f7958a6

Please sign in to comment.