Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/fetch/api/basic/stream-response.js

Issue 2778753002: Import //fetch from Web Platform Tests. (Closed)
Patch Set: Baselines. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698