OLD | NEW |
(Empty) | |
| 1 if (this.document === undefined) { |
| 2 importScripts("/resources/testharness.js"); |
| 3 importScripts("../resources/utils.js"); |
| 4 } |
| 5 |
| 6 function streamBody(reader, test, count) { |
| 7 return reader.read().then(function(data) { |
| 8 if (!data.done && count < 2) { |
| 9 count += 1; |
| 10 return streamBody(reader, test, count); |
| 11 } else { |
| 12 test.step(function() { |
| 13 assert_true(count >= 2, "Retrieve body progressively"); |
| 14 }); |
| 15 } |
| 16 }); |
| 17 } |
| 18 |
| 19 //simulate streaming: |
| 20 //count is large enough to let the UA deliver the body before it is completely r
etrieved |
| 21 promise_test(function(test) { |
| 22 return fetch(RESOURCES_DIR + "trickle.py?ms=30&count=100").then(function(resp)
{ |
| 23 var count = 0; |
| 24 if (resp.body) |
| 25 return streamBody(resp.body.getReader(), test, count); |
| 26 else |
| 27 test.step(function() { |
| 28 assert_unreached( "Body does not exist in response"); |
| 29 }); |
| 30 }); |
| 31 }, "Stream response's body"); |
| 32 |
| 33 done(); |
OLD | NEW |