Bug 1452112 [wpt PR 9928] - add Response test for propagating underlying ReadableStream error, a=testonly
authorChris <AnthumChris@users.noreply.github.com>
Mon, 09 Apr 2018 14:36:52 +0000
changeset 413461 bda1d5269dd93793f8ec5a48c70829eae7f8230b
parent 413460 15ae72c25b3ca9bf231619c2e655a63b483bd7e6
child 413462 4c7588bbe70bd29f11b0ce8f78a9c89b1709df4b
push id33850
push userapavel@mozilla.com
push dateMon, 16 Apr 2018 09:53:48 +0000
treeherdermozilla-central@6276ec7ebbf3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1452112
milestone61.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 1452112 [wpt PR 9928] - add Response test for propagating underlying ReadableStream error, a=testonly Automatic update from web-platform-testsAdd Response test for propagating underlying ReadableStream error When a Response is constructed with ReadableStream, errors originating in that ReadableStream need to propagate to the Response during a Promise rejection. Tests throw errors in start() and pull() methods. Closes https://github.com/whatwg/fetch/issues/676. wpt-commits: e4f8dadcaf45593c1ddd579654250231c7499ed6 wpt-pr: 9928 wpt-commits: e4f8dadcaf45593c1ddd579654250231c7499ed6 wpt-pr: 9928
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/fetch/api/response/response-error-from-stream.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -325193,16 +325193,22 @@
     ]
    ],
    "fetch/api/response/response-consume.html": [
     [
      "/fetch/api/response/response-consume.html",
      {}
     ]
    ],
+   "fetch/api/response/response-error-from-stream.html": [
+    [
+     "/fetch/api/response/response-error-from-stream.html",
+     {}
+    ]
+   ],
    "fetch/api/response/response-error.html": [
     [
      "/fetch/api/response/response-error.html",
      {}
     ]
    ],
    "fetch/api/response/response-idl.html": [
     [
@@ -550516,16 +550522,20 @@
   "fetch/api/response/response-consume-stream.html": [
    "7e990d212ef225ac8475803e01b1772086dbc08d",
    "testharness"
   ],
   "fetch/api/response/response-consume.html": [
    "936272bddf1a090267343fc7f8ab3669da98d27d",
    "testharness"
   ],
+  "fetch/api/response/response-error-from-stream.html": [
+   "74d58d1e907f49a3b9812786d8a3467159514c64",
+   "testharness"
+  ],
   "fetch/api/response/response-error.html": [
    "06489e75d56cbbdbfee903bea7e39c549310ba3e",
    "testharness"
   ],
   "fetch/api/response/response-idl.html": [
    "d94cfadf60dc146f80f7c1dc9937d7841600f9ef",
    "testharness"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/fetch/api/response/response-error-from-stream.html
@@ -0,0 +1,69 @@
+<!doctype html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>Response Receives Propagated Error from ReadableStream</title>
+    <script src="/resources/testharness.js"></script>
+    <script src="/resources/testharnessreport.js"></script>
+  </head>
+  <body>
+    <script>
+      function CustomTestError() {
+        const error = Error();
+        error.name = 'custom-test-error';
+        return error;
+      }
+
+      function newStreamWithStartError() {
+        return new ReadableStream({
+          start(controller) {
+            controller.error(CustomTestError());
+          }
+        })
+      }
+
+      function newStreamWithPullError() {
+        return new ReadableStream({
+          pull(controller) {
+            controller.error(CustomTestError());
+          }
+        })
+      }
+
+      function runRequestPromiseTest(stream, responseReaderMethod, testDescription) {
+        promise_test(test => {
+          return promise_rejects(
+            test,
+            CustomTestError(),
+            new Response(stream)[responseReaderMethod](),
+            'CustomTestError should propagate'
+          )
+        }, testDescription)
+      }
+
+
+      promise_test(test => {
+        return promise_rejects(test, CustomTestError(), newStreamWithStartError().getReader().read(), 'CustomTestError should propagate')
+      }, "ReadableStreamDefaultReader Promise receives ReadableStream start() Error")
+
+      promise_test(test => {
+        return promise_rejects(test, CustomTestError(), newStreamWithPullError().getReader().read(), 'CustomTestError should propagate')
+      }, "ReadableStreamDefaultReader Promise receives ReadableStream pull() Error")
+
+
+      // test start() errors for all Body reader methods
+      runRequestPromiseTest(newStreamWithStartError(), 'arrayBuffer', 'ReadableStream start() Error propagates to Response.arrayBuffer() Promise');
+      runRequestPromiseTest(newStreamWithStartError(), 'blob',        'ReadableStream start() Error propagates to Response.blob() Promise');
+      runRequestPromiseTest(newStreamWithStartError(), 'formData',    'ReadableStream start() Error propagates to Response.formData() Promise');
+      runRequestPromiseTest(newStreamWithStartError(), 'json',        'ReadableStream start() Error propagates to Response.json() Promise');
+      runRequestPromiseTest(newStreamWithStartError(), 'text',        'ReadableStream start() Error propagates to Response.text() Promise');
+
+      // test pull() errors for all Body reader methods
+      runRequestPromiseTest(newStreamWithPullError(), 'arrayBuffer', 'ReadableStream pull() Error propagates to Response.arrayBuffer() Promise');
+      runRequestPromiseTest(newStreamWithPullError(), 'blob',        'ReadableStream pull() Error propagates to Response.blob() Promise');
+      runRequestPromiseTest(newStreamWithPullError(), 'formData',    'ReadableStream pull() Error propagates to Response.formData() Promise');
+      runRequestPromiseTest(newStreamWithPullError(), 'json',        'ReadableStream pull() Error propagates to Response.json() Promise');
+      runRequestPromiseTest(newStreamWithPullError(), 'text',        'ReadableStream pull() Error propagates to Response.text() Promise');
+    </script>
+  </body>
+</html>