| 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 promise_test(function(t) { | 5 promise_test(function(t) { |
| 6 return fetch('http://') | 6 return fetch('http://') |
| 7 .then( | 7 .then( |
| 8 t.unreached_func('fetch of invalid URL must fail'), | 8 t.unreached_func('fetch of invalid URL must fail'), |
| 9 function() {}); | 9 function() {}); |
| 10 }, 'Fetch invalid URL'); | 10 }, 'Fetch invalid URL'); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 'text/plain;charset=US-ASCII'); | 30 'text/plain;charset=US-ASCII'); |
| 31 assert_equals(size(response.headers), 1); | 31 assert_equals(size(response.headers), 1); |
| 32 return response.text(); | 32 return response.text(); |
| 33 }) | 33 }) |
| 34 .then(function(text) { | 34 .then(function(text) { |
| 35 assert_equals(text, 'Foobar'); | 35 assert_equals(text, 'Foobar'); |
| 36 }); | 36 }); |
| 37 }, 'fetch data: URL'); | 37 }, 'fetch data: URL'); |
| 38 | 38 |
| 39 promise_test(function(t) { | 39 promise_test(function(t) { |
| 40 return fetch('data:,Foobar', |
| 41 { |
| 42 method: 'POST', |
| 43 body: 'Test' |
| 44 }) |
| 45 .then(function(response) { |
| 46 assert_equals(response.status, 200); |
| 47 assert_equals(response.statusText, 'OK'); |
| 48 assert_equals(response.headers.get('Content-Type'), |
| 49 'text/plain;charset=US-ASCII'); |
| 50 assert_equals(size(response.headers), 1); |
| 51 return response.text(); |
| 52 }) |
| 53 .then(function(text) { |
| 54 assert_equals(text, 'Foobar'); |
| 55 }); |
| 56 }, 'fetch data: URL with the POST method'); |
| 57 |
| 58 promise_test(function(t) { |
| 40 return fetch('data:text/html;charset=utf-8;base64,5paH5a2X') | 59 return fetch('data:text/html;charset=utf-8;base64,5paH5a2X') |
| 41 .then(function(response) { | 60 .then(function(response) { |
| 42 assert_equals(response.status, 200); | 61 assert_equals(response.status, 200); |
| 43 assert_equals(response.statusText, 'OK'); | 62 assert_equals(response.statusText, 'OK'); |
| 44 assert_equals(response.headers.get('Content-Type'), | 63 assert_equals(response.headers.get('Content-Type'), |
| 45 'text/html;charset=utf-8'); | 64 'text/html;charset=utf-8'); |
| 46 assert_equals(size(response.headers), 1); | 65 assert_equals(size(response.headers), 1); |
| 47 return response.text(); | 66 return response.text(); |
| 48 }) | 67 }) |
| 49 .then(function(text) { | 68 .then(function(text) { |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 assert_true(req.bodyUsed); | 384 assert_true(req.bodyUsed); |
| 366 }, 'Calling fetch() disturbs body if not null'); | 385 }, 'Calling fetch() disturbs body if not null'); |
| 367 | 386 |
| 368 test(t => { | 387 test(t => { |
| 369 var req = new Request('/', {method: 'POST'}); | 388 var req = new Request('/', {method: 'POST'}); |
| 370 fetch(req); | 389 fetch(req); |
| 371 assert_false(req.bodyUsed); | 390 assert_false(req.bodyUsed); |
| 372 }, 'Calling fetch() doesn\'t disturb body if null'); | 391 }, 'Calling fetch() doesn\'t disturb body if null'); |
| 373 | 392 |
| 374 done(); | 393 done(); |
| OLD | NEW |