| 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'); |
| 11 | 11 |
| 12 // https://fetch.spec.whatwg.org/#fetching | 12 // https://fetch.spec.whatwg.org/#fetching |
| 13 // Step 4: | 13 // Step 4: |
| 14 // request's url's scheme is not one of "http" and "https" | 14 // request's url's scheme is not one of "http" and "https" |
| 15 // A network error. | 15 // A network error. |
| 16 promise_test(function(t) { | 16 promise_test(function(t) { |
| 17 return fetch('ftp://localhost/') | 17 return fetch('ftp://localhost/') |
| 18 .then( | 18 .then( |
| 19 t.unreached_func('fetch of non-HTTP(S) CORS must fail'), | 19 t.unreached_func('fetch of non-HTTP(S) CORS must fail'), |
| 20 function() {}); | 20 function() {}); |
| 21 }, 'fetch non-HTTP(S) CORS'); | 21 }, 'fetch non-HTTP(S) CORS'); |
| 22 | 22 |
| 23 // Tests for blob: scheme. |
| 24 promise_test(function(t) { |
| 25 var url = URL.createObjectURL(new Blob(['fox'], {type: 'text/fox'})); |
| 26 return fetch(url) |
| 27 .then(function(response) { |
| 28 assert_equals(response.status, 200); |
| 29 assert_equals(response.statusText, 'OK'); |
| 30 assert_equals(response.headers.get('Content-Type'), 'text/fox'); |
| 31 assert_equals(response.headers.get('Content-Length'), '3'); |
| 32 assert_equals(size(response.headers), 2); |
| 33 return response.text(); |
| 34 }) |
| 35 .then(function(text) { |
| 36 assert_equals(text, 'fox'); |
| 37 }); |
| 38 }, 'fetch blob: URL'); |
| 39 |
| 40 promise_test(function(t) { |
| 41 var url = URL.createObjectURL(new Blob(['fox'], {type: 'text/fox'})); |
| 42 return fetch(url + 'invalid') |
| 43 .then( |
| 44 t.unreached_func('fetching non-existent blob: URL must fail'), |
| 45 function() {}); |
| 46 }, 'fetch non-existent blob: URL'); |
| 47 |
| 23 // https://fetch.spec.whatwg.org/#concept-basic-fetch | 48 // https://fetch.spec.whatwg.org/#concept-basic-fetch |
| 24 // The last statement: | 49 // The last statement: |
| 25 // Otherwise | 50 // Otherwise |
| 26 // Return a network error. | 51 // Return a network error. |
| 27 promise_test(function(t) { | 52 promise_test(function(t) { |
| 28 return fetch('foobar://localhost/', {mode: 'no-cors'}) | 53 return fetch('foobar://localhost/', {mode: 'no-cors'}) |
| 29 .then( | 54 .then( |
| 30 t.unreached_func('scheme not listed in basic fetch spec must fail'), | 55 t.unreached_func('scheme not listed in basic fetch spec must fail'), |
| 31 function() {}); | 56 function() {}); |
| 32 }, 'fetch of scheme not listed in basic fetch spec'); | 57 }, 'fetch of scheme not listed in basic fetch spec'); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 function runInfiniteFetchLoop() { | 312 function runInfiniteFetchLoop() { |
| 288 fetch('dummy.html') | 313 fetch('dummy.html') |
| 289 .then(function() { runInfiniteFetchLoop(); }); | 314 .then(function() { runInfiniteFetchLoop(); }); |
| 290 } | 315 } |
| 291 runInfiniteFetchLoop(); | 316 runInfiniteFetchLoop(); |
| 292 }, | 317 }, |
| 293 'Destroying the execution context while fetch is happening should not ' + | 318 'Destroying the execution context while fetch is happening should not ' + |
| 294 'cause a crash.'); | 319 'cause a crash.'); |
| 295 | 320 |
| 296 done(); | 321 done(); |
| OLD | NEW |