Bug 1480754 [wpt PR 12296] - [Streams] Add a test for piping to errored, a=testonly
authorAdam Rice <ricea@chromium.org>
Wed, 15 Aug 2018 01:01:45 +0000
changeset 431715 fd45f512c9a1d551d1758f3d0bc02ac8ac2a1701
parent 431714 bb9b9e349c199ecf6081232a7af2abd31ecec5d1
child 431716 d7b4176ba7e16ef8268e4f9fd3b0815b95a260de
push id34451
push userebalazs@mozilla.com
push dateThu, 16 Aug 2018 09:25:15 +0000
treeherdermozilla-central@161817e6d127 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1480754, 12296
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1480754 [wpt PR 12296] - [Streams] Add a test for piping to errored, a=testonly Automatic update from web-platform-tests[Streams] Add a test for piping to errored (#12296) The test 'Piping from an errored readable stream to an errored writable stream' was misnamed, as the destination writable was erroring, not errored. Rename it. Add a variant of the test where pipeTo() isn't called until the destination is errored. Split other tests for errored writables into erroring + errored versions. -- wpt-commits: 8ab7aace6a65a045a1b8823988623afc4c1e4f09 wpt-pr: 12296
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/streams/piping/multiple-propagation.js
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -631799,17 +631799,17 @@
    "d71ce15f5d248656b958490fcd0f7bf867e9db10",
    "testharness"
   ],
   "streams/piping/multiple-propagation.html": [
    "92e3ff04c74d1ba585091db28cf9d71173bb7ff8",
    "testharness"
   ],
   "streams/piping/multiple-propagation.js": [
-   "4edc7c180e117779c7ded1f90eeed236ef82c0ae",
+   "87119ebc65f6d05045c2e9069b7576e87f26a8ca",
    "support"
   ],
   "streams/piping/multiple-propagation.serviceworker.https.html": [
    "63f7b00b40fbd877ced7a164bbbc13fd145722c7",
    "testharness"
   ],
   "streams/piping/multiple-propagation.sharedworker.html": [
    "6396c645cd542652f5f83885c28817f21ee1dfde",
--- a/testing/web-platform/tests/streams/piping/multiple-propagation.js
+++ b/testing/web-platform/tests/streams/piping/multiple-propagation.js
@@ -7,39 +7,73 @@ if (self.importScripts) {
 }
 
 const error1 = new Error('error1!');
 error1.name = 'error1';
 
 const error2 = new Error('error2!');
 error2.name = 'error2';
 
+function createErroredWritableStream(t) {
+  return Promise.resolve().then(() => {
+    const ws = recordingWritableStream({
+      start(c) {
+        c.error(error2);
+      }
+    });
+
+    const writer = ws.getWriter();
+    return promise_rejects(t, error2, writer.closed, 'the writable stream must be errored with error2')
+        .then(() => {
+          writer.releaseLock();
+          assert_array_equals(ws.events, []);
+          return ws;
+        });
+  });
+}
+
 promise_test(t => {
   const rs = recordingReadableStream({
     start(c) {
       c.error(error1);
     }
   });
   const ws = recordingWritableStream({
     start(c) {
       c.error(error2);
     }
   });
 
-  // Trying to abort a stream that was errored will give that error back
+  // Trying to abort a stream that is erroring will give the writable's error
   return promise_rejects(t, error2, rs.pipeTo(ws), 'pipeTo must reject with the writable stream\'s error').then(() => {
     assert_array_equals(rs.events, []);
     assert_array_equals(ws.events, []);
 
     return Promise.all([
       promise_rejects(t, error1, rs.getReader().closed, 'the readable stream must be errored with error1'),
       promise_rejects(t, error2, ws.getWriter().closed, 'the writable stream must be errored with error2')
     ]);
   });
 
+}, 'Piping from an errored readable stream to an erroring writable stream');
+
+promise_test(t => {
+  const rs = recordingReadableStream({
+    start(c) {
+      c.error(error1);
+    }
+  });
+
+  return createErroredWritableStream(t)
+      .then(ws => promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the readable stream\'s error'))
+      .then(() => {
+        assert_array_equals(rs.events, []);
+
+        return promise_rejects(t, error1, rs.getReader().closed, 'the readable stream must be errored with error1');
+      });
 }, 'Piping from an errored readable stream to an errored writable stream');
 
 promise_test(t => {
   const rs = recordingReadableStream({
     start(c) {
       c.error(error1);
     }
   });
@@ -56,16 +90,33 @@ promise_test(t => {
     assert_array_equals(ws.events, []);
 
     return Promise.all([
       promise_rejects(t, error1, rs.getReader().closed, 'the readable stream must be errored with error1'),
       promise_rejects(t, error2, ws.getWriter().closed, 'the writable stream must be errored with error2')
     ]);
   });
 
+}, 'Piping from an errored readable stream to an erroring writable stream; preventAbort = true');
+
+promise_test(t => {
+  const rs = recordingReadableStream({
+    start(c) {
+      c.error(error1);
+    }
+  });
+  return createErroredWritableStream(t)
+  .then(ws => promise_rejects(t, error1, rs.pipeTo(ws, { preventAbort: true }),
+                              'pipeTo must reject with the readable stream\'s error'))
+  .then(() => {
+    assert_array_equals(rs.events, []);
+
+    return promise_rejects(t, error1, rs.getReader().closed, 'the readable stream must be errored with error1');
+  });
+
 }, 'Piping from an errored readable stream to an errored writable stream; preventAbort = true');
 
 promise_test(t => {
   const rs = recordingReadableStream({
     start(c) {
       c.error(error1);
     }
   });
@@ -132,16 +183,32 @@ promise_test(t => {
     assert_array_equals(ws.events, []);
 
     return Promise.all([
       rs.getReader().closed,
       promise_rejects(t, error1, ws.getWriter().closed, 'the writable stream must be errored with error1')
     ]);
   });
 
+}, 'Piping from a closed readable stream to an erroring writable stream');
+
+promise_test(t => {
+  const rs = recordingReadableStream({
+    start(c) {
+      c.close();
+    }
+  });
+  return createErroredWritableStream(t)
+  .then(ws => promise_rejects(t, error2, rs.pipeTo(ws), 'pipeTo must reject with the writable stream\'s error'))
+  .then(() => {
+    assert_array_equals(rs.events, []);
+
+    return rs.getReader().closed;
+  });
+
 }, 'Piping from a closed readable stream to an errored writable stream');
 
 promise_test(() => {
   const rs = recordingReadableStream({
     start(c) {
       c.close();
     }
   });