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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/stream-reader.js

Issue 2311063003: [Fetch API] Call endRead sooner to avoid recursive invocation (Closed)
Patch Set: fix Created 4 years, 3 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 if (self.importScripts) { 1 if (self.importScripts) {
2 importScripts('/fetch/resources/fetch-test-helpers.js'); 2 importScripts('/fetch/resources/fetch-test-helpers.js');
3 importScripts('/streams/resources/rs-utils.js'); 3 importScripts('/streams/resources/rs-utils.js');
4 } 4 }
5 5
6 promise_test(function(t) { 6 promise_test(function(t) {
7 return fetch('/fetch/resources/doctype.html').then(function(res) { 7 return fetch('/fetch/resources/doctype.html').then(function(res) {
8 var stream = res.body; 8 var stream = res.body;
9 var reader = stream.getReader(); 9 var reader = stream.getReader();
10 assert_throws({name: 'TypeError'}, function() { stream.getReader() }); 10 assert_throws({name: 'TypeError'}, function() { stream.getReader() });
(...skipping 19 matching lines...) Expand all
30 for (var chunk of chunks) { 30 for (var chunk of chunks) {
31 buffer.set(new Uint8Array(chunk), offset); 31 buffer.set(new Uint8Array(chunk), offset);
32 offset += chunk.byteLength; 32 offset += chunk.byteLength;
33 } 33 }
34 return new TextDecoder().decode(buffer); 34 return new TextDecoder().decode(buffer);
35 }).then(function(string) { 35 }).then(function(string) {
36 assert_equals(string, '<!DOCTYPE html>\n'); 36 assert_equals(string, '<!DOCTYPE html>\n');
37 }); 37 });
38 }, 'read contents with ReadableStreamReader'); 38 }, 'read contents with ReadableStreamReader');
39 39
40 promise_test(() => {
41 let reader;
42 let body;
tyoshino (SeeGerritForStatus) 2016/09/06 10:58:06 body no longer need to be declared outside?
yhirano 2016/09/06 11:03:07 Done.
43 return fetch('/fetch/resources/progressive.php').then(res => {
44 body = res.body;
tyoshino (SeeGerritForStatus) 2016/09/06 10:58:06 ah, this line itself is no longer needed.
yhirano 2016/09/06 11:03:07 Done.
45 reader = res.body.getReader();
46 return Promise.all([reader.read(), reader.read(), reader.read()]);
47 }).then(() => {
48 reader.releaseLock();
49 // We expect the test finishes without crashing.
50 });
51 }, 'parallel read');
52
40 promise_test(function(t) { 53 promise_test(function(t) {
41 return fetch('/fetch/resources/progressive.php').then(function(res) { 54 return fetch('/fetch/resources/progressive.php').then(function(res) {
42 assert_false(res.bodyUsed); 55 assert_false(res.bodyUsed);
43 var reader = res.body.getReader(); 56 var reader = res.body.getReader();
44 assert_false(res.bodyUsed); 57 assert_false(res.bodyUsed);
45 return res.text().then(unreached_fulfillment(t), function() { 58 return res.text().then(unreached_fulfillment(t), function() {
46 // text() should fail because the body is locked. 59 // text() should fail because the body is locked.
47 // TODO(yhirano): Use finally once it gets available. 60 // TODO(yhirano): Use finally once it gets available.
48 reader.releaseLock(); 61 reader.releaseLock();
49 }); 62 });
(...skipping 29 matching lines...) Expand all
79 assert_true(res.bodyUsed); 92 assert_true(res.bodyUsed);
80 assert_false(clone.bodyUsed); 93 assert_false(clone.bodyUsed);
81 return clone.arrayBuffer(); 94 return clone.arrayBuffer();
82 }).then(function(r) { 95 }).then(function(r) {
83 assert_equals(r.byteLength, 190); 96 assert_equals(r.byteLength, 190);
84 assert_true(clone.bodyUsed); 97 assert_true(clone.bodyUsed);
85 }); 98 });
86 }, 'Cancelling stream should not affect cloned one.'); 99 }, 'Cancelling stream should not affect cloned one.');
87 100
88 done(); 101 done();
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698