<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[189693] trunk/LayoutTests</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/189693">189693</a></dd>
<dt>Author</dt> <dd>calvaris@igalia.com</dd>
<dt>Date</dt> <dd>2015-09-14 01:35:52 -0700 (Mon, 14 Sep 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Streams API] Add readable stream templated tests for writable streams
https://bugs.webkit.org/show_bug.cgi?id=148304

Reviewed by Darin Adler.

* streams/reference-implementation/readable-stream-templated-expected.txt: Added new expectations.
* streams/reference-implementation/readable-stream-templated.html: New writable stream tests.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsstreamsreferenceimplementationreadablestreamtemplatedexpectedtxt">trunk/LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstreamsreferenceimplementationreadablestreamtemplatedhtml">trunk/LayoutTests/streams/reference-implementation/readable-stream-templated.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (189692 => 189693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-09-14 08:34:21 UTC (rev 189692)
+++ trunk/LayoutTests/ChangeLog        2015-09-14 08:35:52 UTC (rev 189693)
</span><span class="lines">@@ -1,5 +1,15 @@
</span><span class="cx"> 2015-09-14  Xabier Rodriguez Calvar  &lt;calvaris@igalia.com&gt;
</span><span class="cx"> 
</span><ins>+        [Streams API] Add readable stream templated tests for writable streams
+        https://bugs.webkit.org/show_bug.cgi?id=148304
+
+        Reviewed by Darin Adler.
+
+        * streams/reference-implementation/readable-stream-templated-expected.txt: Added new expectations.
+        * streams/reference-implementation/readable-stream-templated.html: New writable stream tests.
+
+2015-09-14  Xabier Rodriguez Calvar  &lt;calvaris@igalia.com&gt;
+
</ins><span class="cx">         [Streams API] Add pipe-to-options writable stream tests
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=148297
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsstreamsreferenceimplementationreadablestreamtemplatedexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt (189692 => 189693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt        2015-09-14 08:34:21 UTC (rev 189692)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt        2015-09-14 08:35:52 UTC (rev 189693)
</span><span class="lines">@@ -18,6 +18,8 @@
</span><span class="cx"> PASS cancel() should return a distinct fulfilled promise each time 
</span><span class="cx"> PASS locked should be false 
</span><span class="cx"> PASS getReader() should be OK 
</span><ins>+FAIL piping to a WritableStream in the writable state should close the writable stream Can't find variable: WritableStream
+FAIL piping to a WritableStream in the writable state with { preventClose: true } should do nothing Can't find variable: WritableStream
</ins><span class="cx"> PASS should be able to acquire multiple readers, since they are all auto-released 
</span><span class="cx"> PASS Running templatedRSClosedReader with ReadableStream reader (closed before getting reader) 
</span><span class="cx"> PASS read() should fulfill with { value: undefined, done: true } 
</span><span class="lines">@@ -35,6 +37,8 @@
</span><span class="cx"> PASS cancel() should return a distinct fulfilled promise each time 
</span><span class="cx"> PASS locked should be false 
</span><span class="cx"> PASS getReader() should be OK 
</span><ins>+FAIL piping to a WritableStream in the writable state should close the writable stream Can't find variable: WritableStream
+FAIL piping to a WritableStream in the writable state with { preventClose: true } should do nothing Can't find variable: WritableStream
</ins><span class="cx"> PASS should be able to acquire multiple readers, since they are all auto-released 
</span><span class="cx"> PASS Running templatedRSClosedReader with ReadableStream reader (closed via cancel after getting reader) 
</span><span class="cx"> PASS read() should fulfill with { value: undefined, done: true } 
</span><span class="lines">@@ -43,6 +47,7 @@
</span><span class="cx"> PASS closed should fulfill with undefined 
</span><span class="cx"> PASS cancel() should return a distinct fulfilled promise each time 
</span><span class="cx"> PASS Running templatedRSErrored with ReadableStream (errored via call in start) 
</span><ins>+FAIL piping to a WritableStream in the writable state should abort the writable stream Can't find variable: WritableStream
</ins><span class="cx"> PASS getReader() should return a reader that acts errored 
</span><span class="cx"> PASS read() twice should give the error each time 
</span><span class="cx"> PASS locked should be false 
</span><span class="lines">@@ -52,9 +57,14 @@
</span><span class="cx"> PASS reader cancel() should return a distinct rejected promise each time 
</span><span class="cx"> PASS should be able to acquire multiple readers, since they are all auto-released 
</span><span class="cx"> PASS Running templatedRSErrored with ReadableStream (errored via returning a rejected promise in start) 
</span><ins>+FAIL piping to a WritableStream in the writable state should abort the writable stream Can't find variable: WritableStream
</ins><span class="cx"> PASS getReader() should return a reader that acts errored 
</span><span class="cx"> PASS read() twice should give the error each time 
</span><span class="cx"> PASS locked should be false 
</span><ins>+PASS Running templatedRSErroredAsyncOnly with ReadableStream (errored via returning a rejected promise in start) reader 
+FAIL piping with no options Can't find variable: WritableStream
+FAIL piping with { preventAbort: false } Can't find variable: WritableStream
+FAIL piping with { preventAbort: true } Can't find variable: WritableStream
</ins><span class="cx"> PASS Running templatedRSErroredReader with ReadableStream (errored via returning a rejected promise in start) reader 
</span><span class="cx"> PASS closed should reject with the error 
</span><span class="cx"> PASS read() should reject with the error 
</span><span class="lines">@@ -69,6 +79,27 @@
</span><span class="cx"> PASS calling read() twice with waiting will eventually give both chunks 
</span><span class="cx"> PASS read() should return distinct promises each time 
</span><span class="cx"> PASS cancel() after a read() should still give that single read result 
</span><ins>+PASS Running templatedRSTwoChunksClosed with ReadableStream (two chunks enqueued, then closed) 
+FAIL piping with no options and no destination errors Can't find variable: WritableStream
+FAIL piping with { preventClose: false } and no destination errors Can't find variable: WritableStream
+FAIL piping with { preventClose: true } and no destination errors Can't find variable: WritableStream
+FAIL piping with { preventClose: false } and a destination with that errors synchronously Can't find variable: WritableStream
+FAIL piping with { preventClose: true } and a destination with that errors synchronously Can't find variable: WritableStream
+FAIL piping with { preventClose: true } and a destination that errors on the last chunk Can't find variable: WritableStream
+PASS Running templatedRSTwoChunksClosed with ReadableStream (two chunks enqueued async, then closed) 
+FAIL piping with no options and no destination errors Can't find variable: WritableStream
+FAIL piping with { preventClose: false } and no destination errors Can't find variable: WritableStream
+FAIL piping with { preventClose: true } and no destination errors Can't find variable: WritableStream
+FAIL piping with { preventClose: false } and a destination with that errors synchronously Can't find variable: WritableStream
+FAIL piping with { preventClose: true } and a destination with that errors synchronously Can't find variable: WritableStream
+FAIL piping with { preventClose: true } and a destination that errors on the last chunk Can't find variable: WritableStream
+PASS Running templatedRSTwoChunksClosed with ReadableStream (two chunks enqueued via pull, then closed) 
+FAIL piping with no options and no destination errors Can't find variable: WritableStream
+FAIL piping with { preventClose: false } and no destination errors Can't find variable: WritableStream
+FAIL piping with { preventClose: true } and no destination errors Can't find variable: WritableStream
+FAIL piping with { preventClose: false } and a destination with that errors synchronously Can't find variable: WritableStream
+FAIL piping with { preventClose: true } and a destination with that errors synchronously Can't find variable: WritableStream
+FAIL piping with { preventClose: true } and a destination that errors on the last chunk Can't find variable: WritableStream
</ins><span class="cx"> PASS Running templatedRSTwoChunksClosedReader with ReadableStream (two chunks enqueued, then closed) reader 
</span><span class="cx"> PASS third read(), without waiting, should give { value: undefined, done: true } 
</span><span class="cx"> PASS third read, with waiting, should give { value: undefined, done: true } 
</span></span></pre></div>
<a id="trunkLayoutTestsstreamsreferenceimplementationreadablestreamtemplatedhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/streams/reference-implementation/readable-stream-templated.html (189692 => 189693)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/reference-implementation/readable-stream-templated.html        2015-09-14 08:34:21 UTC (rev 189692)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream-templated.html        2015-09-14 08:35:52 UTC (rev 189693)
</span><span class="lines">@@ -58,6 +58,69 @@
</span><span class="cx">         rs.getReader(); // getReader() should not throw.
</span><span class="cx">     }, 'getReader() should be OK');
</span><span class="cx"> 
</span><ins>+    var test2 = async_test('piping to a WritableStream in the writable state should close the writable stream');
+    test2.step(function() {
+        var closeCalled = false;
+
+        var rs = factory();
+
+        var startPromise = Promise.resolve();
+        var ws = new WritableStream({
+            start: function() {
+                return startPromise;
+            },
+            write: function() {
+                assert_unreached('Unexpected write call');
+            },
+            close: function() {
+                closeCalled = true;
+            },
+            abort: function() {
+                assert_unreached('Unexpected abort call');
+            }
+        });
+
+        startPromise.then(test2.step_func(function() {
+            assert_equals(ws.state, 'writable', 'writable stream should start in writable state');
+
+            return rs.pipeTo(ws).then(test2.step_func(function() {
+                assert_true(closeCalled);
+                assert_equals(ws.state, 'closed', 'writable stream should become closed');
+                test2.done('underlying source close should be called');
+            }));
+        })).catch(test2.step_func(function(e) { assert_unreached(e); }));
+    });
+
+    var test3 = async_test('piping to a WritableStream in the writable state with { preventClose: true } should do nothing');
+    test3.step(function() {
+        var rs = factory();
+
+        var startPromise = Promise.resolve();
+        var ws = new WritableStream({
+            start: function() {
+                return startPromise;
+            },
+            write: function() {
+                assert_unreached('Unexpected write call');
+            },
+            close: function() {
+                assert_unreached('Unexpected close call');
+            },
+            abort: function() {
+                assert_unreached('Unexpected abort call');
+            }
+        });
+
+        startPromise.then(test3.step_func(function() {
+            assert_equals(ws.state, 'writable', 'writable stream should start in writable state');
+
+            return rs.pipeTo(ws, { preventClose: true }).then(test3.step_func(function() {
+                assert_equals(ws.state, 'writable', 'writable stream should still be writable');
+                test3.done('pipeTo promise should be fulfilled');
+            }));
+        })).catch(test3.step_func(function(e) { assert_unreached(e); }));
+    });
+
</ins><span class="cx">     test(function() {
</span><span class="cx">         var rs = factory();
</span><span class="cx"> 
</span><span class="lines">@@ -72,44 +135,78 @@
</span><span class="cx">     test(function() {
</span><span class="cx">     }, 'Running templatedRSErrored with ' + label);
</span><span class="cx"> 
</span><del>-    var test1 = async_test('getReader() should return a reader that acts errored');
</del><ins>+    var test1 = async_test('piping to a WritableStream in the writable state should abort the writable stream');
</ins><span class="cx">     test1.step(function() {
</span><span class="cx">         var rs = factory();
</span><ins>+
+        var startPromise = Promise.resolve();
+        var ws = new WritableStream({
+            start: function() {
+                return startPromise;
+            },
+            write: function() {
+                assert_unreached('Unexpected write call');
+            },
+            close: function() {
+                assert_reached('Unexpected close call');
+            },
+            abort: function(reason) {
+                assert_equals(reason, error);
+            }
+        });
+
+        startPromise.then(test1.step_func(function() {
+            assert_equals(ws.state, 'writable');
+
+            rs.pipeTo(ws).then(
+                test1.step_func(function() { assert_unreached('pipeTo promise should not be fulfilled'); }),
+                test1.step_func(function(e) {
+                    assert_equals(e, error, 'pipeTo promise should be rejected with the passed error');
+                    assert_equals(ws.state, 'errored', 'writable stream should become errored');
+                    test1.done();
+                })
+            );
+        }));
+    });
+
+    var test2 = async_test('getReader() should return a reader that acts errored');
+    test2.step(function() {
+        var rs = factory();
</ins><span class="cx">         var promisesCount = 0;
</span><span class="cx"> 
</span><span class="cx">         var reader = rs.getReader();
</span><span class="cx"> 
</span><del>-        reader.closed.catch(test1.step_func(function(e) {
</del><ins>+        reader.closed.catch(test2.step_func(function(e) {
</ins><span class="cx">             assert_equals(e, error, 'reader.closed should reject with the error');
</span><span class="cx">             if (++promisesCount === 2)
</span><del>-                test1.done();
</del><ins>+                test2.done();
</ins><span class="cx">         }));
</span><del>-        reader.read().catch(test1.step_func(function(e) {
</del><ins>+        reader.read().catch(test2.step_func(function(e) {
</ins><span class="cx">             assert_equals(e, error, 'reader.read() should reject with the error');
</span><span class="cx">             if (++promisesCount === 2)
</span><del>-                test1.done();
</del><ins>+                test2.done();
</ins><span class="cx">         }));
</span><span class="cx">     });
</span><span class="cx"> 
</span><del>-    var test2 = async_test('read() twice should give the error each time');
-    test2.step(function() {
</del><ins>+    var test3 = async_test('read() twice should give the error each time');
+    test3.step(function() {
</ins><span class="cx">         var rs = factory();
</span><span class="cx">         var promiseCount = 0;
</span><span class="cx"> 
</span><span class="cx">         var reader = rs.getReader();
</span><span class="cx"> 
</span><del>-        reader.read().catch(test2.step_func(function(e) {
</del><ins>+        reader.read().catch(test3.step_func(function(e) {
</ins><span class="cx">             assert_equals(e, error, 'reader.read() should reject with the error');
</span><span class="cx">             assert_equals(++promiseCount, 1);
</span><span class="cx">         }));
</span><del>-        reader.read().catch(test2.step_func(function(e) {
</del><ins>+        reader.read().catch(test3.step_func(function(e) {
</ins><span class="cx">             assert_equals(e, error, 'reader.read() should reject with the error');
</span><span class="cx">             assert_equals(++promiseCount, 2);
</span><span class="cx">         }));
</span><del>-        reader.closed.catch(test2.step_func(function(e) {
</del><ins>+        reader.closed.catch(test3.step_func(function(e) {
</ins><span class="cx">             assert_equals(e, error, 'reader.closed should reject with the error');
</span><span class="cx">             assert_equals(++promiseCount, 3);
</span><del>-            test2.done();
</del><ins>+            test3.done();
</ins><span class="cx">         }));
</span><span class="cx">    });
</span><span class="cx"> 
</span><span class="lines">@@ -120,6 +217,81 @@
</span><span class="cx">     }, 'locked should be false');
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+function templatedRSErroredAsyncOnly(label, factory, error) {
+    test(function() {
+    }, 'Running templatedRSErroredAsyncOnly with ' + label);
+
+    var test1 = async_test('piping with no options');
+    test1.step(function() {
+        var closeCalled = false;
+
+        var rs = factory();
+
+        var ws = new WritableStream({
+            abort: function(r) {
+                assert_equals(r, error, 'reason passed to abort should equal the source error');
+            }
+        });
+
+        rs.pipeTo(ws).catch(test1.step_func(function(e) {
+            assert_equals(ws.state, 'errored', 'destination should be errored');
+            assert_equals(e, error, 'rejection reason of pipeToPromise should be the source error');
+            assert_true(closeCalled);
+            test1.done();
+        }));
+
+        ws.closed.catch(test1.step_func(function(e) {
+            assert_equals(e, error, 'rejection reason of dest closed should be the source error');
+            closeCalled = true;
+        }))
+    });
+
+    var test2 = async_test('piping with { preventAbort: false }');
+    test2.step(function() {
+        var abortCalled = false;
+        var closeRejected = false;
+
+        var rs = factory();
+
+        var ws = new WritableStream({
+            abort: function(r) {
+                assert_equals(r, error, 'reason passed to abort should equal the source error');
+                abortCalled = true;
+            }
+        });
+
+        rs.pipeTo(ws, { preventAbort: false }).catch(test2.step_func(function(e) {
+            assert_equals(ws.state, 'errored', 'destination should be errored');
+            assert_equals(e, error, 'rejection reason of pipeToPromise should be the source error');
+            assert_true(abortCalled);
+            assert_true(closeRejected);
+            test2.done();
+        }));
+
+        ws.closed.catch(test2.step_func(function(e) {
+            assert_equals(e, error, 'rejection reason of dest closed should be the source error');
+            closeRejected = true;
+        }));
+    });
+
+    var test3 = async_test('piping with { preventAbort: true }');
+    test3.step(function() {
+        var rs = factory();
+
+        var ws = new WritableStream({
+            abort: function() {
+                assert_unreached('underlying sink abort should not be called');
+            }
+        });
+
+        rs.pipeTo(ws, { preventAbort: true }).catch(test3.step_func(function(e) {
+            assert_equals(ws.state, 'writable', 'destination should remain writable');
+            assert_equals(e, error, 'rejection reason of pipeToPromise should be the source error');
+            test3.done();
+        }));
+   });
+};
+
</ins><span class="cx"> function templatedRSErroredSyncOnly(label, factory, error) {
</span><span class="cx">     test(function() {
</span><span class="cx">     }, 'Running templatedRSErroredSyncOnly with ' + label);
</span><span class="lines">@@ -198,6 +370,164 @@
</span><span class="cx">     }, 'should be able to acquire multiple readers, since they are all auto-released');
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+function templatedRSTwoChunksClosed(label, factory, error) {
+    test(function() {
+    }, 'Running templatedRSTwoChunksClosed with ' + label);
+
+    var test1 = async_test('piping with no options and no destination errors');
+    test1.step(function() {
+        var rs = factory();
+
+        var chunksWritten = [];
+        var ws = new WritableStream({
+            abort: function() {
+                assert_unreached('unexpected abort call');
+            },
+            write: function(chunk) {
+                chunksWritten.push(chunk);
+            }
+        });
+
+        rs.pipeTo(ws).then(test1.step_func(function() {
+            assert_equals(ws.state, 'closed', 'destination should be closed');
+            assert_array_equals(chunksWritten, chunks);
+            test1.done();
+        }));
+    });
+
+    var test2 = async_test('piping with { preventClose: false } and no destination errors');
+    test2.step(function() {
+        var rs = factory();
+
+        var chunksWritten = [];
+        var ws = new WritableStream({
+            abort: function() {
+                assert_unreached('unexpected abort call');
+            },
+            write: function(chunk) {
+                chunksWritten.push(chunk);
+            }
+        });
+
+        rs.pipeTo(ws).then(test2.step_func(function() {
+            assert_equals(ws.state, 'closed', 'destination should be closed');
+            assert_array_equals(chunksWritten, chunks);
+            test2.done();
+        }));
+    });
+
+    var test3 = async_test('piping with { preventClose: true } and no destination errors');
+    test3.step(function() {
+        var rs = factory();
+
+        var chunksWritten = [];
+        var ws = new WritableStream({
+            close: function() {
+                assert_unreached('unexpected close call');
+            },
+            abort: function() {
+                assert_unreached('unexpected abort call');
+            },
+            write: function(chunk) {
+                chunksWritten.push(chunk);
+            }
+        });
+
+        rs.pipeTo(ws, { preventClose: true }).then(test3.step_func(function() {
+            assert_equals(ws.state, 'writable', 'destination should be writable');
+            assert_array_equals(chunksWritten, chunks);
+            test3.done();
+        }));
+    });
+
+    var test4 = async_test('piping with { preventClose: false } and a destination with that errors synchronously');
+    test4.step(function() {
+        var rs = factory();
+
+        var theError = new Error('!!!');
+        var ws = new WritableStream({
+            close: function() {
+                assert_unreached('unexpected close call');
+            },
+            abort: function() {
+                assert_unreached('unexpected abort call');
+            },
+            write: function() {
+                throw theError;
+            }
+        });
+
+        rs.pipeTo(ws, { preventClose: false }).then(
+            test4.step_func(function() { assert_unreached('pipeTo promise should not fulfill'); }),
+            test4.step_func(function(e) {
+                assert_equals(e, theError, 'pipeTo promise should reject with the write error');
+                test4.done();
+            })
+        );
+    });
+
+    var test5 = async_test('piping with { preventClose: true } and a destination with that errors synchronously');
+    test5.step(function() {
+        var rs = factory();
+
+        var theError = new Error('!!!');
+        var ws = new WritableStream({
+            close: function() {
+                assert_unreached('unexpected close call');
+            },
+            abort: function() {
+                assert_unreached('unexpected abort call');
+            },
+            write: function() {
+                throw theError;
+            }
+        });
+
+        rs.pipeTo(ws, { preventClose: true }).then(
+            test5.step_func(function() { assert_unreached('pipeTo promise should not fulfill'); }),
+            test5.step_func(function(e) {
+                assert_equals(e, theError, 'pipeTo promise should reject with the write error');
+                test5.done();
+            })
+        );
+    });
+
+    var test6 = async_test('piping with { preventClose: true } and a destination that errors on the last chunk');
+    test6.step(function() {
+        var rs = factory();
+
+        var theError = new Error('!!!');
+        var chunkCounter = 0;
+        var ws = new WritableStream(
+            {
+                close: function() {
+                    assert_unreached('unexpected close call');
+                },
+                abort: function() {
+                    assert_unreached('unexpected abort call');
+                },
+                write: function() {
+                    if (++chunkCounter === 2) {
+                        return new Promise(test6.step_func(function(r, reject) { setTimeout(test6.step_func(function() { reject(theError); }), 200); }));
+                    }
+                }
+            },
+            {
+                highWaterMark: Infinity,
+                size: function() { return 1; }
+            }
+        );
+
+        rs.pipeTo(ws, { preventClose: true }).then(
+            test6.step_func(function() { assert_unreached('pipeTo promise should not fulfill'); }),
+            test6.step_func(function(e) {
+                assert_equals(e, theError, 'pipeTo promise should reject with the write error');
+                test6.done();
+            })
+        );
+    });
+};
+
</ins><span class="cx"> function templatedRSEmptyReader(label, factory) {
</span><span class="cx">     test(function() {
</span><span class="cx">     }, 'Running templatedRSEmptyReader with ' + label);
</span><span class="lines">@@ -741,6 +1071,13 @@
</span><span class="cx">     theError
</span><span class="cx"> );
</span><span class="cx"> 
</span><ins>+templatedRSErroredAsyncOnly('ReadableStream (errored via returning a rejected promise in start) reader', function() {
+    return new ReadableStream({
+        start: function() { return Promise.reject(theError); }
+    })},
+    theError
+);
+
</ins><span class="cx"> templatedRSErroredReader('ReadableStream (errored via returning a rejected promise in start) reader', function() {
</span><span class="cx">     return streamAndDefaultReader(new ReadableStream({
</span><span class="cx">         start: function() {
</span><span class="lines">@@ -784,6 +1121,44 @@
</span><span class="cx">     chunks
</span><span class="cx"> );
</span><span class="cx"> 
</span><ins>+templatedRSTwoChunksClosed('ReadableStream (two chunks enqueued, then closed)', function() {
+    return new ReadableStream({
+        start: function(c) {
+            c.enqueue(chunks[0]);
+            c.enqueue(chunks[1]);
+            c.close();
+        }
+    })},
+    chunks
+);
+
+templatedRSTwoChunksClosed('ReadableStream (two chunks enqueued async, then closed)', function() {
+    return new ReadableStream({
+        start: function(c) {
+            setTimeout(function() { c.enqueue(chunks[0]); }, 100);
+            setTimeout(function() { c.enqueue(chunks[1]); }, 200);
+            setTimeout(function() { c.close(); }, 300);
+        }
+    })},
+    chunks
+);
+
+templatedRSTwoChunksClosed('ReadableStream (two chunks enqueued via pull, then closed)', function() {
+    var pullCall = 0;
+
+    return new ReadableStream({
+        pull:function(c) {
+            if (pullCall &gt;= chunks.length) {
+                c.close();
+            } else {
+                c.enqueue(chunks[pullCall++]);
+            }
+        }
+    });
+},
+chunks
+);
+
</ins><span class="cx"> templatedRSTwoChunksClosedReader('ReadableStream (two chunks enqueued, then closed) reader', function() {
</span><span class="cx">     var doClose;
</span><span class="cx">     var stream = new ReadableStream({
</span></span></pre>
</div>
</div>

</body>
</html>