OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf-8"> |
| 5 <title>Response consume blob and http bodies</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 src="../resources/utils.js"></script> |
| 14 <script> |
| 15 |
| 16 promise_test(function(test) { |
| 17 return new Response(new Blob([], { "type" : "text/plain" })).body.cancel(); |
| 18 }, "Cancelling a starting blob Response stream"); |
| 19 |
| 20 promise_test(function(test) { |
| 21 var response = new Response(new Blob(["This is data"], { "type" : "text/plai
n" })); |
| 22 var reader = response.body.getReader(); |
| 23 reader.read(); |
| 24 return reader.cancel(); |
| 25 }, "Cancelling a loading blob Response stream"); |
| 26 |
| 27 promise_test(function(test) { |
| 28 var response = new Response(new Blob(["T"], { "type" : "text/plain" })); |
| 29 var reader = response.body.getReader(); |
| 30 |
| 31 var closedPromise = reader.closed.then(function() { |
| 32 return reader.cancel(); |
| 33 }); |
| 34 reader.read(); |
| 35 return closedPromise; |
| 36 }, "Cancelling a closed blob Response stream"); |
| 37 |
| 38 promise_test(function(test) { |
| 39 return fetch(RESOURCES_DIR + "trickle.py?ms=30&count=100").then(function(res
ponse) { |
| 40 return response.body.cancel(); |
| 41 }); |
| 42 }, "Cancelling a starting Response stream"); |
| 43 |
| 44 promise_test(function() { |
| 45 return fetch(RESOURCES_DIR + "trickle.py?ms=30&count=100").then(function(res
ponse) { |
| 46 var reader = response.body.getReader(); |
| 47 return reader.read().then(function() { |
| 48 return reader.cancel(); |
| 49 }); |
| 50 }); |
| 51 }, "Cancelling a loading Response stream"); |
| 52 |
| 53 promise_test(function() { |
| 54 return fetch(RESOURCES_DIR + "top.txt").then(function(response) { |
| 55 var reader = response.body.getReader(); |
| 56 var closedPromise = reader.closed.then(function() { |
| 57 return reader.cancel(); |
| 58 }); |
| 59 reader.read(); |
| 60 return closedPromise; |
| 61 }); |
| 62 }, "Cancelling a closed Response stream"); |
| 63 |
| 64 </script> |
| 65 </body> |
| 66 </html> |
OLD | NEW |