OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf-8"> |
| 5 <title>Consuming Response body after getting a ReadableStream</title> |
| 6 <meta name="help" href="https://fetch.spec.whatwg.org/#response"> |
| 7 <meta name="help" href="https://fetch.spec.whatwg.org/#body-mixin"> |
| 8 <meta name="author" title="Canon Research France" href="https://www.crf.cano
n.fr"> |
| 9 <script src="/resources/testharness.js"></script> |
| 10 <script src="/resources/testharnessreport.js"></script> |
| 11 </head> |
| 12 <body> |
| 13 <script> |
| 14 |
| 15 function createResponseWithDisturbedReadableStream(callback) { |
| 16 return fetch("../resources/data.json").then(function(response) { |
| 17 var reader = response.body.getReader(); |
| 18 reader.read(); |
| 19 return callback(response); |
| 20 }); |
| 21 } |
| 22 |
| 23 promise_test(function(test) { |
| 24 return createResponseWithDisturbedReadableStream(function(response) { |
| 25 return promise_rejects(test, new TypeError(), response.blob()); |
| 26 }); |
| 27 }, "Getting blob after reading the Response body"); |
| 28 |
| 29 promise_test(function(test) { |
| 30 return createResponseWithDisturbedReadableStream(function(response) { |
| 31 return promise_rejects(test, new TypeError(), response.text()); |
| 32 }); |
| 33 }, "Getting text after reading the Response body"); |
| 34 |
| 35 promise_test(function(test) { |
| 36 return createResponseWithDisturbedReadableStream(function(response) { |
| 37 return promise_rejects(test, new TypeError(), response.json()); |
| 38 }); |
| 39 }, "Getting json after reading the Response body"); |
| 40 |
| 41 promise_test(function(test) { |
| 42 return createResponseWithDisturbedReadableStream(function(response) { |
| 43 return promise_rejects(test, new TypeError(), response.arrayBuffer()); |
| 44 }); |
| 45 }, "Getting arrayBuffer after reading the Response body"); |
| 46 |
| 47 </script> |
| 48 </body> |
| 49 </html> |
OLD | NEW |