OLD | NEW |
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 readStream(reader, values) { | 5 function readStream(reader, values) { |
6 reader.read().then(function(r) { | 6 reader.read().then(function(r) { |
7 if (!r.done) { | 7 if (!r.done) { |
8 values.push(r.value); | 8 values.push(r.value); |
9 readStream(reader, values); | 9 readStream(reader, values); |
10 } | 10 } |
(...skipping 26 matching lines...) Expand all Loading... |
37 for (var chunk of chunks) { | 37 for (var chunk of chunks) { |
38 actual += decoder.decode(chunk, {stream: true}); | 38 actual += decoder.decode(chunk, {stream: true}); |
39 } | 39 } |
40 // Put an empty buffer without the stream option to end decoding. | 40 // Put an empty buffer without the stream option to end decoding. |
41 actual += decoder.decode(new Uint8Array(0)); | 41 actual += decoder.decode(new Uint8Array(0)); |
42 assert_equals(actual, '<!DOCTYPE html>\n'); | 42 assert_equals(actual, '<!DOCTYPE html>\n'); |
43 }) | 43 }) |
44 }, 'FetchStreamTest'); | 44 }, 'FetchStreamTest'); |
45 | 45 |
46 sequential_promise_test(function(test) { | 46 sequential_promise_test(function(test) { |
47 return fetch('/fetch/resources/doctype.html') | 47 return fetch('/fetch/resources/progressive.php') |
48 .then(function(response) { | 48 .then(function(response) { |
49 var p1 = response.text(); | 49 var p1 = response.text(); |
| 50 // Because progressive.php takes some time to load, we expect |
| 51 // response.text() is not yet completed here. |
50 var p2 = response.text().then(function() { | 52 var p2 = response.text().then(function() { |
51 return Promise.reject(new Error('resolved unexpectedly')); | 53 return Promise.reject(new Error('resolved unexpectedly')); |
52 }, function(e) { | 54 }, function(e) { |
53 return e; | 55 return e; |
54 }); | 56 }); |
55 return Promise.all([p1, p2]); | 57 return Promise.all([p1, p2]); |
56 }) | 58 }) |
57 .then(function(results) { | 59 .then(function(results) { |
58 assert_equals(results[0], '<!DOCTYPE html>\n'); | 60 assert_equals(results[0].length, 190); |
59 assert_equals(results[1].name, 'TypeError'); | 61 assert_equals(results[1].name, 'TypeError'); |
60 }) | 62 }) |
61 }, 'FetchTwiceTest'); | 63 }, 'FetchTwiceTest'); |
62 | 64 |
63 sequential_promise_test(function(test) { | 65 sequential_promise_test(function(test) { |
64 return fetch('/fetch/resources/doctype.html') | 66 return fetch('/fetch/resources/doctype.html') |
65 .then(function(response) { | 67 .then(function(response) { |
66 return response.arrayBuffer(); | 68 return response.arrayBuffer(); |
67 }) | 69 }) |
68 .then(function(b) { | 70 .then(function(b) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 reader.releaseLock(); | 144 reader.releaseLock(); |
143 return response.arrayBuffer(); | 145 return response.arrayBuffer(); |
144 }) | 146 }) |
145 .then(function(buffer) { | 147 .then(function(buffer) { |
146 actual += decoder.decode(buffer); | 148 actual += decoder.decode(buffer); |
147 assert_equals(actual, expected); | 149 assert_equals(actual, expected); |
148 }) | 150 }) |
149 }, 'PartiallyReadFromStreamAndReadArrayBufferTest'); | 151 }, 'PartiallyReadFromStreamAndReadArrayBufferTest'); |
150 | 152 |
151 done(); | 153 done(); |
OLD | NEW |