Chromium Code Reviews| 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 sequential_promise_test(function(t) { | 5 sequential_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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 }, 'Fetch result of 404 response'); | 48 }, 'Fetch result of 404 response'); |
| 49 | 49 |
| 50 sequential_promise_test(function(t) { | 50 sequential_promise_test(function(t) { |
| 51 var request = new Request( | 51 var request = new Request( |
| 52 '/serviceworker/resources/fetch-status.php?status=200#fragment'); | 52 '/serviceworker/resources/fetch-status.php?status=200#fragment'); |
| 53 | 53 |
| 54 // The url attribute's getter must return request's url, | 54 // The url attribute's getter must return request's url, |
| 55 // serialized with the exclude fragment flag set. | 55 // serialized with the exclude fragment flag set. |
| 56 assert_equals(request.url, | 56 assert_equals(request.url, |
| 57 BASE_ORIGIN + '/serviceworker/resources/fetch-status.php?status=200'); | 57 BASE_ORIGIN + '/serviceworker/resources/fetch-status.php?status=200'); |
| 58 assert_equals(request.context, ''); | |
| 58 | 59 |
| 59 return fetch(request) | 60 return fetch(request) |
| 60 .then(function(response) { | 61 .then(function(response) { |
| 61 assert_equals(response.status, 200); | 62 assert_equals(response.status, 200); |
| 62 assert_equals(response.statusText, 'OK'); | 63 assert_equals(response.statusText, 'OK'); |
| 63 // The url attribute's getter must return the empty string | 64 // The url attribute's getter must return the empty string |
| 64 // if response's url is null and response's url, | 65 // if response's url is null and response's url, |
| 65 // serialized with the exclude fragment flag set, otherwise. | 66 // serialized with the exclude fragment flag set, otherwise. |
| 66 assert_equals(response.url, | 67 assert_equals(response.url, |
| 67 BASE_ORIGIN + | 68 BASE_ORIGIN + |
| 68 '/serviceworker/resources/fetch-status.php?status=200'); | 69 '/serviceworker/resources/fetch-status.php?status=200'); |
| 70 assert_equals(request.context, ''); | |
|
horo
2015/04/09 13:27:31
nit: fix indent
shiva.jm
2015/04/10 09:27:10
Done.
| |
| 69 }); | 71 }); |
| 70 }, 'Request/response url attribute getter with fragment'); | 72 }, 'Request/response url attribute getter with fragment'); |
| 71 | 73 |
| 72 sequential_promise_test(function(t) { | 74 sequential_promise_test(function(t) { |
| 73 var redirect_target_url = | 75 var redirect_target_url = |
| 74 BASE_ORIGIN + '/serviceworker/resources/fetch-status.php?status=200'; | 76 BASE_ORIGIN + '/serviceworker/resources/fetch-status.php?status=200'; |
| 75 var redirect_original_url = | 77 var redirect_original_url = |
| 76 BASE_ORIGIN + '/serviceworker/resources/redirect.php?Redirect=' + | 78 BASE_ORIGIN + '/serviceworker/resources/redirect.php?Redirect=' + |
| 77 redirect_target_url; | 79 redirect_target_url; |
| 78 | 80 |
| 79 var request = new Request(redirect_original_url); | 81 var request = new Request(redirect_original_url); |
| 80 assert_equals(request.url, redirect_original_url, | 82 assert_equals(request.url, redirect_original_url, |
| 81 'Request\'s url is the original URL'); | 83 'Request\'s url is the original URL'); |
| 84 assert_equals(request.context, ''); | |
| 82 | 85 |
| 83 return fetch(request) | 86 return fetch(request) |
| 84 .then(function(response) { | 87 .then(function(response) { |
| 85 assert_equals(response.status, 200); | 88 assert_equals(response.status, 200); |
| 86 assert_equals(response.statusText, 'OK'); | 89 assert_equals(response.statusText, 'OK'); |
| 87 assert_equals(response.url, redirect_target_url, | 90 assert_equals(response.url, redirect_target_url, |
| 88 'Response\'s url is locationURL'); | 91 'Response\'s url is locationURL'); |
| 89 assert_equals(request.url, redirect_original_url, | 92 assert_equals(request.url, redirect_original_url, |
| 90 'Request\'s url remains the original URL'); | 93 'Request\'s url remains the original URL'); |
| 94 assert_equals(request.context, ''); | |
| 91 }); | 95 }); |
| 92 }, 'Request/response url attribute getter with redirect'); | 96 }, 'Request/response url attribute getter with redirect'); |
| 93 | 97 |
| 94 function evalJsonp(text) { | 98 function evalJsonp(text) { |
| 95 return new Promise(function(resolve) { | 99 return new Promise(function(resolve) { |
| 96 var report = resolve; | 100 var report = resolve; |
| 97 // text must contain report() call. | 101 // text must contain report() call. |
| 98 eval(text); | 102 eval(text); |
| 99 }); | 103 }); |
| 100 } | 104 } |
| 101 | 105 |
| 102 sequential_promise_test(function(t) { | 106 sequential_promise_test(function(t) { |
| 103 var request = | 107 var request = |
| 104 new Request('/serviceworker/resources/fetch-access-control.php', | 108 new Request('/serviceworker/resources/fetch-access-control.php', |
| 105 { | 109 { |
| 106 method: 'POST', | 110 method: 'POST', |
| 107 body: new Blob(['Test Blob'], {type: 'test/type'}) | 111 body: new Blob(['Test Blob'], {type: 'test/type'}) |
| 108 }); | 112 }); |
| 113 assert_equals(request.context, ''); | |
| 109 return fetch(request) | 114 return fetch(request) |
| 110 .then(function(response) { return response.text(); }) | 115 .then(function(response) { return response.text(); }) |
| 111 .then(evalJsonp) | 116 .then(evalJsonp) |
| 112 .then(function(result) { | 117 .then(function(result) { |
| 113 assert_equals(result.method, 'POST'); | 118 assert_equals(result.method, 'POST'); |
| 114 assert_equals(result.body, 'Test Blob'); | 119 assert_equals(result.body, 'Test Blob'); |
| 120 assert_equals(request.context, ''); | |
|
horo
2015/04/09 13:27:31
nit: fox indent
shiva.jm
2015/04/10 09:27:10
Done.
| |
| 115 }); | 121 }); |
| 116 }, 'Fetch with Blob body test'); | 122 }, 'Fetch with Blob body test'); |
| 117 | 123 |
| 118 sequential_promise_test(function(t) { | 124 sequential_promise_test(function(t) { |
| 119 var request = new Request( | 125 var request = new Request( |
| 120 '/serviceworker/resources/fetch-access-control.php', | 126 '/serviceworker/resources/fetch-access-control.php', |
| 121 {method: 'POST', body: 'Test String'}); | 127 {method: 'POST', body: 'Test String'}); |
| 122 return fetch(request) | 128 return fetch(request) |
| 123 .then(function(response) { return response.text(); }) | 129 .then(function(response) { return response.text(); }) |
| 124 .then(evalJsonp) | 130 .then(evalJsonp) |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 fetch('dummy.html') | 203 fetch('dummy.html') |
| 198 .then(function() { runInfiniteFetchLoop(); }); | 204 .then(function() { runInfiniteFetchLoop(); }); |
| 199 } | 205 } |
| 200 runInfiniteFetchLoop(); | 206 runInfiniteFetchLoop(); |
| 201 }, | 207 }, |
| 202 'Destroying the execution context while fetch is happening should not ' + | 208 'Destroying the execution context while fetch is happening should not ' + |
| 203 'cause a crash.'); | 209 'cause a crash.'); |
| 204 | 210 |
| 205 sequential_promise_test_done(); | 211 sequential_promise_test_done(); |
| 206 done(); | 212 done(); |
| OLD | NEW |