| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + scope; | 108 host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + scope; |
| 109 return install_cross_origin_worker(t, worker_for_scopes(['']), scope) | 109 return install_cross_origin_worker(t, worker_for_scopes(['']), scope) |
| 110 .then(() => fetch(remote_url)) | 110 .then(() => fetch(remote_url)) |
| 111 .then(response => {}); | 111 .then(response => {}); |
| 112 }, 'Service Worker that fallback to network should not crash.'); | 112 }, 'Service Worker that fallback to network should not crash.'); |
| 113 | 113 |
| 114 promise_test(t => { | 114 promise_test(t => { |
| 115 var ff_scope = 'foreign-fetch/scope/controlled?basic'; | 115 var ff_scope = 'foreign-fetch/scope/controlled?basic'; |
| 116 var remote_url = | 116 var remote_url = |
| 117 host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + ff_scope; | 117 host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + ff_scope; |
| 118 var scope = 'resources/simple.html'; | 118 var scope = 'resources/simple.html?fetch'; |
| 119 var worker = 'resources/empty-worker.js'; | 119 var worker = 'resources/empty-worker.js'; |
| 120 return install_cross_origin_worker(t, worker_for_scopes(['']), ff_scope) | 120 return install_cross_origin_worker(t, worker_for_scopes(['']), ff_scope) |
| 121 .then(() => service_worker_unregister_and_register(t, worker, scope)) | 121 .then(() => service_worker_unregister_and_register(t, worker, scope)) |
| 122 .then(r => { | 122 .then(r => { |
| 123 add_completion_callback(() => r.unregister()); | 123 add_completion_callback(() => r.unregister()); |
| 124 return wait_for_state(t, r.installing, 'activated'); | 124 return wait_for_state(t, r.installing, 'activated'); |
| 125 }) | 125 }) |
| 126 .then(() => with_iframe(scope)) | 126 .then(() => with_iframe(scope)) |
| 127 .then(frame => frame.contentWindow.fetch(remote_url)) | 127 .then(frame => frame.contentWindow.fetch(remote_url)) |
| 128 .then(response => response.text()) | 128 .then(response => response.text()) |
| 129 .then(response_text => { | 129 .then(response_text => { |
| 130 assert_equals(response_text, 'Foreign Fetch'); | 130 assert_equals(response_text, 'Foreign Fetch'); |
| 131 }); | 131 }); |
| 132 }, 'Foreign fetch can intercept requests from SW controlled pages.'); | 132 }, 'Foreign fetch can intercept fetch requests from SW controlled pages.'); |
| 133 |
| 134 promise_test(t => { |
| 135 var ff_scope = 'foreign-fetch/scope/controlled?script'; |
| 136 var remote_url = |
| 137 host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + ff_scope; |
| 138 var scope = 'resources/simple.html?script'; |
| 139 var worker = 'resources/empty-worker.js'; |
| 140 return install_cross_origin_worker(t, worker_for_scopes(['']), ff_scope) |
| 141 .then(() => service_worker_unregister_and_register(t, worker, scope)) |
| 142 .then(r => { |
| 143 add_completion_callback(() => r.unregister()); |
| 144 return wait_for_state(t, r.installing, 'activated'); |
| 145 }) |
| 146 .then(() => with_iframe(scope)) |
| 147 .then(frame => new Promise(resolve => { |
| 148 frame.contentWindow.DidLoad = resolve; |
| 149 let script = frame.contentWindow.document.createElement('script'); |
| 150 script.setAttribute('src', remote_url); |
| 151 script.setAttribute('crossorigin', 'use-credentials'); |
| 152 frame.contentWindow.document.head.appendChild(script); |
| 153 })) |
| 154 .then(response_text => { |
| 155 assert_equals(response_text, 'Foreign Fetch'); |
| 156 }); |
| 157 }, 'Foreign fetch can intercept resource requests from SW controlled pages.'); |
| 133 | 158 |
| 134 promise_test(t => { | 159 promise_test(t => { |
| 135 var scope = 'simple.txt?meta'; | 160 var scope = 'simple.txt?meta'; |
| 136 var remote_url = | 161 var remote_url = |
| 137 host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + scope; | 162 host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + scope; |
| 138 return install_cross_origin_worker(t, worker_for_scopes(['']), scope) | 163 return install_cross_origin_worker(t, worker_for_scopes(['']), scope) |
| 139 .then(() => fetch(remote_url, {mode: 'no-cors'})) | 164 .then(() => fetch(remote_url, {mode: 'no-cors'})) |
| 140 .then(response => response.json()) | 165 .then(response => response.json()) |
| 141 .then(response_data => { | 166 .then(response_data => { |
| 142 assert_equals(self.location.href, response_data.referrer); | 167 assert_equals(self.location.href, response_data.referrer); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 return install_cross_origin_worker(t, worker_for_scopes(['']), scope, | 201 return install_cross_origin_worker(t, worker_for_scopes(['']), scope, |
| 177 host_info.AUTHENTICATED_ORIGIN) | 202 host_info.AUTHENTICATED_ORIGIN) |
| 178 .then(() => fetch_from_iframe(host_info.HTTPS_REMOTE_ORIGIN, remote_url)) | 203 .then(() => fetch_from_iframe(host_info.HTTPS_REMOTE_ORIGIN, remote_url)) |
| 179 .then(response => assert_equals(response, 'Success: Foreign Fetch')) | 204 .then(response => assert_equals(response, 'Success: Foreign Fetch')) |
| 180 .then(() => fetch_from_iframe(host_info.UNAUTHENTICATED_ORIGIN, | 205 .then(() => fetch_from_iframe(host_info.UNAUTHENTICATED_ORIGIN, |
| 181 remote_url)) | 206 remote_url)) |
| 182 .then(response => assert_equals(response, | 207 .then(response => assert_equals(response, |
| 183 'Error: TypeError: Failed to fetch')); | 208 'Error: TypeError: Failed to fetch')); |
| 184 }, 'Service Worker does not intercept fetches from an insecure context.'); | 209 }, 'Service Worker does not intercept fetches from an insecure context.'); |
| 185 | 210 |
| 211 promise_test(t => { |
| 212 var scope = 'fetch-access-control.php?basic&ACAOrigin=*&ACAMethods=SPECIAL'; |
| 213 var remote_url = |
| 214 host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + scope; |
| 215 return install_cross_origin_worker(t, worker_for_scopes(['']), scope) |
| 216 .then(() => fetch(remote_url, {method: 'SPECIAL'})) |
| 217 .then(response => response.text()) |
| 218 .then(response_text => assert_true(response_text.startsWith('report('))); |
| 219 }, 'Service Worker does not intercept fetches with CORS preflight'); |
| 220 |
| 186 </script> | 221 </script> |
| 187 </body> | 222 </body> |
| OLD | NEW |