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

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 return fetch('/fetch/resources/progressive.php').then(res => {
43 reader = res.body.getReader();
44 return Promise.all([reader.read(), reader.read(), reader.read()]);
45 }).then(() => {
46 reader.releaseLock();
47 // We expect the test finishes without crashing.
48 });
49 }, 'parallel read');
50
40 promise_test(function(t) { 51 promise_test(function(t) {
41 return fetch('/fetch/resources/progressive.php').then(function(res) { 52 return fetch('/fetch/resources/progressive.php').then(function(res) {
42 assert_false(res.bodyUsed); 53 assert_false(res.bodyUsed);
43 var reader = res.body.getReader(); 54 var reader = res.body.getReader();
44 assert_false(res.bodyUsed); 55 assert_false(res.bodyUsed);
45 return res.text().then(unreached_fulfillment(t), function() { 56 return res.text().then(unreached_fulfillment(t), function() {
46 // text() should fail because the body is locked. 57 // text() should fail because the body is locked.
47 // TODO(yhirano): Use finally once it gets available. 58 // TODO(yhirano): Use finally once it gets available.
48 reader.releaseLock(); 59 reader.releaseLock();
49 }); 60 });
(...skipping 29 matching lines...) Expand all
79 assert_true(res.bodyUsed); 90 assert_true(res.bodyUsed);
80 assert_false(clone.bodyUsed); 91 assert_false(clone.bodyUsed);
81 return clone.arrayBuffer(); 92 return clone.arrayBuffer();
82 }).then(function(r) { 93 }).then(function(r) {
83 assert_equals(r.byteLength, 190); 94 assert_equals(r.byteLength, 190);
84 assert_true(clone.bodyUsed); 95 assert_true(clone.bodyUsed);
85 }); 96 });
86 }, 'Cancelling stream should not affect cloned one.'); 97 }, 'Cancelling stream should not affect cloned one.');
87 98
88 done(); 99 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