OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../resources/testharness.js"></script> | 2 <script src="../resources/testharness.js"></script> |
3 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
4 <script src="../resources/get-host-info.js"></script> | 4 <script src="../resources/get-host-info.js"></script> |
5 <script src="resources/test-helpers.js"></script> | 5 <script src="resources/test-helpers.js"></script> |
6 <script src="resources/foreign-fetch-helpers.js"></script> | 6 <script src="resources/foreign-fetch-helpers.js"></script> |
7 <body> | 7 <body> |
8 <script> | 8 <script> |
9 var host_info = get_host_info(); | 9 var host_info = get_host_info(); |
10 | 10 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 'Error: TypeError: Failed to fetch')); | 229 'Error: TypeError: Failed to fetch')); |
230 }, 'Service Worker does not intercept fetches from an insecure context.'); | 230 }, 'Service Worker does not intercept fetches from an insecure context.'); |
231 | 231 |
232 promise_test(t => { | 232 promise_test(t => { |
233 var scope = 'fetch-access-control.php?basic&ACAOrigin=*&ACAMethods=SPECIAL'; | 233 var scope = 'fetch-access-control.php?basic&ACAOrigin=*&ACAMethods=SPECIAL'; |
234 var remote_url = | 234 var remote_url = |
235 host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + scope; | 235 host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + scope; |
236 return install_cross_origin_worker(t, worker_for_scopes(['']), scope) | 236 return install_cross_origin_worker(t, worker_for_scopes(['']), scope) |
237 .then(() => fetch(remote_url, {method: 'SPECIAL'})) | 237 .then(() => fetch(remote_url, {method: 'SPECIAL'})) |
238 .then(response => response.text()) | 238 .then(response => response.text()) |
239 .then(response_text => assert_true(response_text.startsWith('report('))) | |
240 // Do the whole thing twice to test CORS preflight cache behavior. | |
241 .then(() => fetch(remote_url, {method: 'SPECIAL'})) | |
yhirano
2016/12/20 07:42:26
Isn't it better to have two separate tests?
Marijn Kruisselbrink
2016/12/20 17:28:28
I don't think so. I don't like having dependencies
| |
242 .then(response => response.text()) | |
239 .then(response_text => assert_true(response_text.startsWith('report('))); | 243 .then(response_text => assert_true(response_text.startsWith('report('))); |
240 }, 'Service Worker does not intercept fetches with CORS preflight'); | 244 }, 'Service Worker does not intercept fetches with CORS preflight'); |
241 | 245 |
242 promise_test(t => { | 246 promise_test(t => { |
243 var scope = 'simple.txt?null'; | 247 var scope = 'simple.txt?null'; |
244 var remote_url = | 248 var remote_url = |
245 host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + scope; | 249 host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + scope; |
246 return install_cross_origin_worker(t, worker_for_scopes(['']), scope) | 250 return install_cross_origin_worker(t, worker_for_scopes(['']), scope) |
247 .then(() => promise_rejects(t, new TypeError(), fetch(remote_url))); | 251 .then(() => promise_rejects(t, new TypeError(), fetch(remote_url))); |
248 }, 'Foreign fetch rejects if resolved with a null response.'); | 252 }, 'Foreign fetch rejects if resolved with a null response.'); |
249 </script> | 253 </script> |
250 </body> | 254 </body> |
OLD | NEW |