| 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 consume(reader) { | 5 function consume(reader) { |
| 6 var chunks = []; | 6 var chunks = []; |
| 7 function rec(reader) { | 7 function rec(reader) { |
| 8 return reader.read().then(function(r) { | 8 return reader.read().then(function(r) { |
| 9 if (r.done) { | 9 if (r.done) { |
| 10 return chunks; | 10 return chunks; |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 promise_test(function(t) { | 301 promise_test(function(t) { |
| 302 var res = new Response(new Blob([''])); | 302 var res = new Response(new Blob([''])); |
| 303 return res.blob() | 303 return res.blob() |
| 304 .then(function(blob) { | 304 .then(function(blob) { |
| 305 assert_equals(blob.type, ''); | 305 assert_equals(blob.type, ''); |
| 306 assert_equals(res.headers.get('Content-Type'), null); | 306 assert_equals(res.headers.get('Content-Type'), null); |
| 307 }); | 307 }); |
| 308 }, 'MIME type for Blob'); | 308 }, 'MIME type for Blob'); |
| 309 | 309 |
| 310 promise_test(function(t) { | 310 promise_test(function(t) { |
| 311 var res = new Response(new Blob([''], {type: 'Text/Plain'})); | 311 var res = new Response(new Blob(['hello'], {type: 'Text/Plain'})); |
| 312 return res.blob() | 312 return res.blob() |
| 313 .then(function(blob) { | 313 .then(function(blob) { |
| 314 assert_equals(blob.type, 'text/plain'); | 314 assert_equals(blob.type, 'text/plain'); |
| 315 assert_equals(blob.size, 5); |
| 316 assert_equals(res.headers.get('Content-Type'), 'text/plain'); |
| 317 return res.blob(); |
| 318 }).then(function(blob) { |
| 319 // When we read from a response twice, it returns an empty contents. |
| 320 // But the type should remain. |
| 321 assert_equals(blob.type, 'text/plain'); |
| 322 assert_equals(blob.size, 0); |
| 315 assert_equals(res.headers.get('Content-Type'), 'text/plain'); | 323 assert_equals(res.headers.get('Content-Type'), 'text/plain'); |
| 316 }); | 324 }); |
| 317 }, 'MIME type for Blob with non-empty type'); | 325 }, 'MIME type for Blob with non-empty type'); |
| 318 | 326 |
| 319 promise_test(function(t) { | 327 promise_test(function(t) { |
| 320 var res = new Response(new FormData()); | 328 var res = new Response(new FormData()); |
| 321 return res.blob() | 329 return res.blob() |
| 322 .then(function(blob) { | 330 .then(function(blob) { |
| 323 assert_equals(blob.type.indexOf('multipart/form-data; boundary='), | 331 assert_equals(blob.type.indexOf('multipart/form-data; boundary='), |
| 324 0); | 332 0); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 assert_equals(texts[0], ''); | 427 assert_equals(texts[0], ''); |
| 420 assert_equals(texts[1], ''); | 428 assert_equals(texts[1], ''); |
| 421 return res.body.getReader().read(); | 429 return res.body.getReader().read(); |
| 422 }).then(function(r) { | 430 }).then(function(r) { |
| 423 assert_true(r.done); | 431 assert_true(r.done); |
| 424 assert_equals(r.value, undefined); | 432 assert_equals(r.value, undefined); |
| 425 }); | 433 }); |
| 426 }, 'Read after text()'); | 434 }, 'Read after text()'); |
| 427 | 435 |
| 428 done(); | 436 done(); |
| OLD | NEW |