blob: 307a35e5ad8f7a9e511fe0b172112840533e5930 [file] [log] [blame]
<!DOCTYPE html>
<script src='../../resources/testharness.js'></script>
<script src='../../resources/testharnessreport.js'></script>
<script src='resources/streams-utils.js'></script>
<script>
// This is updated till https://github.com/whatwg/streams/commit/4ba861e6f60c248060811830e11271c84b439cc3
var test1 = async_test('Piping through a duck-typed pass-through transform stream works');
test1.step(function() {
var readableEnd = sequentialReadableStream(5).pipeThrough(duckTypedPassThroughTransform());
readableStreamToArray(readableEnd).then(function(chunks) {
assert_array_equals(chunks, [1, 2, 3, 4, 5]);
test1.done();
}).catch(function(e) { assert_unreached(e); });
});
var test2 = async_test('Piping through an identity transform stream will close the destination when the source closes');
test2.step(function() {
var rs = new ReadableStream({
start: function(c) {
c.enqueue('a');
c.enqueue('b');
c.enqueue('c');
c.close();
}
});
var ts = new TransformStream({
transform: function(chunk, enqueue, done) {
enqueue(chunk);
done();
}
});
var ws = new WritableStream();
rs.pipeThrough(ts).pipeTo(ws).then(function() {
assert_equals(ws.state, 'closed', 'the writable stream was closed');
test2.done();
}).catch(function(e) { assert_unreached(e); });
});
</script>