mirror of
https://github.com/servo/servo.git
synced 2025-06-06 00:25:37 +00:00
Add pipeTo with different readers type
Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
This commit is contained in:
parent
4ed54eee0e
commit
3bdcaf1cf6
1 changed files with 33 additions and 0 deletions
33
tests/wpt/mozilla/tests/mozilla/stream/pipeTo-reader-locks.any.js
vendored
Normal file
33
tests/wpt/mozilla/tests/mozilla/stream/pipeTo-reader-locks.any.js
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
'use strict';
|
||||
|
||||
promise_test(t => {
|
||||
const rs = new ReadableStream();
|
||||
const ws = new WritableStream();
|
||||
|
||||
rs.getReader();
|
||||
|
||||
assert_true(rs.locked, 'sanity check: the ReadableStream starts locked');
|
||||
assert_false(ws.locked, 'sanity check: the WritableStream does not start locked');
|
||||
|
||||
return promise_rejects_js(t, TypeError, rs.pipeTo(ws)).then(() => {
|
||||
assert_false(ws.locked, 'the WritableStream must still be unlocked');
|
||||
});
|
||||
|
||||
}, 'pipeTo must fail if the ReadableStream is locked with a Default reader, and not lock the WritableStream');
|
||||
|
||||
|
||||
promise_test(t => {
|
||||
const rs = new ReadableStream({
|
||||
type: 'bytes',
|
||||
pull(controller) {
|
||||
// No chunks are enqueued; the stream remains readable but empty.
|
||||
}
|
||||
});
|
||||
const ws = new WritableStream();
|
||||
rs.getReader({ mode: 'byob' });
|
||||
assert_true(rs.locked, 'sanity check: the ReadableStream is locked by the BYOB reader');
|
||||
assert_false(ws.locked, 'sanity check: the WritableStream starts unlocked');
|
||||
return promise_rejects_js(t, TypeError, rs.pipeTo(ws)).then(() => {
|
||||
assert_false(ws.locked, 'the WritableStream must remain unlocked after pipeTo rejection');
|
||||
});
|
||||
}, 'pipeTo must fail if the ReadableStream is locked with a BYOB reader, and must not lock the WritableStream');
|
Loading…
Add table
Add a link
Reference in a new issue