gecko-dev/testing/web-platform/tests/fetch/api/response/response-stream-disturbed-by-pipe.any.js
Adam Rice 7836b9c5be Bug 1595736 [wpt PR 20205] - Verify piping disturbs stream synchronously, a=testonly
Automatic update from web-platform-tests
Verify piping disturbs stream synchronously (#20205)

https://github.com/whatwg/streams/pull/1022 changes pipeTo and
pipeThrough to always set the [[disturbed]] slot of the Response's body
to true synchronously.

This test verifies that behaviour.
--

wpt-commits: 760485a4f652813d1f195ee28042c391cf2fdc02
wpt-pr: 20205
2019-11-29 10:56:14 +00:00

15 lines
635 B
JavaScript

test(() => {
const r = new Response(new ReadableStream());
// highWaterMark: 0 means that nothing will actually be read from the body.
r.body.pipeTo(new WritableStream({}, {highWaterMark: 0}));
assert_true(r.bodyUsed, 'bodyUsed should be true');
}, 'using pipeTo on Response body should disturb it synchronously');
test(() => {
const r = new Response(new ReadableStream());
r.body.pipeThrough({
writable: new WritableStream({}, {highWaterMark: 0}),
readable: new ReadableStream()
});
assert_true(r.bodyUsed, 'bodyUsed should be true');
}, 'using pipeThrough on Response body should disturb it synchronously');