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

Side by Side Diff: LayoutTests/http/tests/fetch/script-tests/fetch-body-mixin.js

Issue 795463006: Rename ReadableStream.wait() to ReadableStream.ready. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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 | LayoutTests/http/tests/xmlhttprequest/resources/response-stream.js » ('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('../resources/fetch-test-helpers.js'); 2 importScripts('../resources/fetch-test-helpers.js');
3 } 3 }
4 4
5 function arrayBufferToString(buffer) { 5 function arrayBufferToString(buffer) {
6 return new Promise(function(resolve) { 6 return new Promise(function(resolve) {
7 var reader = new FileReader(); 7 var reader = new FileReader();
8 reader.onload = function() { 8 reader.onload = function() {
9 resolve(reader.result); 9 resolve(reader.result);
10 }; 10 };
11 reader.readAsText(new Blob([buffer])); 11 reader.readAsText(new Blob([buffer]));
12 }); 12 });
13 } 13 }
14 14
15 function readStream(stream, values) { 15 function readStream(stream, values) {
16 while (stream.state === 'readable') { 16 while (stream.state === 'readable') {
17 values.push(stream.read()); 17 values.push(stream.read());
18 } 18 }
19 if (stream.state === 'waiting') { 19 if (stream.state === 'waiting') {
20 return stream.wait().then(function() { 20 return stream.ready.then(function() {
21 readStream(stream, values); 21 readStream(stream, values);
22 }); 22 });
23 } 23 }
24 return stream.closed; 24 return stream.closed;
25 } 25 }
26 26
27 promise_test(function(test) { 27 promise_test(function(test) {
28 var response; 28 var response;
29 return fetch('/fetch/resources/doctype.html') 29 return fetch('/fetch/resources/doctype.html')
30 .then(function(resp) { 30 .then(function(resp) {
31 response = resp; 31 response = resp;
32 return response.body.wait(); 32 return response.body.ready;
33 }) 33 })
34 .then(function() { 34 .then(function() {
35 if (response.body.state !== 'readable') { 35 if (response.body.state !== 'readable') {
36 return Promise.reject(TypeError('stream state get wrong')); 36 return Promise.reject(TypeError('stream state get wrong'));
37 } else { 37 } else {
38 return response.text(); 38 return response.text();
39 } 39 }
40 }) 40 })
41 .then(function(text) { 41 .then(function(text) {
42 assert_equals(text, '<!DOCTYPE html>\n', 'response.body'); 42 assert_equals(text, '<!DOCTYPE html>\n', 'response.body');
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 return fetch('/fetch/resources/doctype.html') 136 return fetch('/fetch/resources/doctype.html')
137 .then(function(response) { 137 .then(function(response) {
138 return response.text(); 138 return response.text();
139 }) 139 })
140 .then(function(text) { 140 .then(function(text) {
141 assert_equals(text, '<!DOCTYPE html>\n'); 141 assert_equals(text, '<!DOCTYPE html>\n');
142 }) 142 })
143 }, 'TextTest'); 143 }, 'TextTest');
144 144
145 done(); 145 done();
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/xmlhttprequest/resources/response-stream.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698