| Index: third_party/WebKit/LayoutTests/external/wpt/streams/piping/pipe-through.js
|
| diff --git a/third_party/WebKit/LayoutTests/external/wpt/streams/piping/pipe-through.js b/third_party/WebKit/LayoutTests/external/wpt/streams/piping/pipe-through.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..910f677a21015b121115767cd17e6f6ec962a0ef
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/external/wpt/streams/piping/pipe-through.js
|
| @@ -0,0 +1,39 @@
|
| +'use strict';
|
| +
|
| +if (self.importScripts) {
|
| + self.importScripts('/resources/testharness.js');
|
| + self.importScripts('../resources/rs-utils.js');
|
| +}
|
| +
|
| +function duckTypedPassThroughTransform() {
|
| + let enqueueInReadable;
|
| + let closeReadable;
|
| +
|
| + return {
|
| + writable: new WritableStream({
|
| + write(chunk) {
|
| + enqueueInReadable(chunk);
|
| + },
|
| +
|
| + close() {
|
| + closeReadable();
|
| + }
|
| + }),
|
| +
|
| + readable: new ReadableStream({
|
| + start(c) {
|
| + enqueueInReadable = c.enqueue.bind(c);
|
| + closeReadable = c.close.bind(c);
|
| + }
|
| + })
|
| + };
|
| +}
|
| +
|
| +promise_test(() => {
|
| + const readableEnd = sequentialReadableStream(5).pipeThrough(duckTypedPassThroughTransform());
|
| +
|
| + return readableStreamToArray(readableEnd).then(chunks =>
|
| + assert_array_equals(chunks, [1, 2, 3, 4, 5]), 'chunks should match');
|
| +}, 'Piping through a duck-typed pass-through transform stream should work');
|
| +
|
| +done();
|
|
|