OLD | NEW |
1 // Adapter for testharness.js-style tests with Service Workers | 1 // Adapter for testharness.js-style tests with Service Workers |
2 | 2 |
3 function service_worker_unregister_and_register(test, url, scope) { | 3 function service_worker_unregister_and_register(test, url, scope) { |
4 if (!scope || scope.length == 0) | 4 if (!scope || scope.length == 0) |
5 return Promise.reject(new Error('tests must define a scope')); | 5 return Promise.reject(new Error('tests must define a scope')); |
6 | 6 |
7 var options = { scope: scope }; | 7 var options = { scope: scope }; |
8 return service_worker_unregister(test, scope) | 8 return service_worker_unregister(test, scope) |
9 .then(function() { | 9 .then(function() { |
10 return navigator.serviceWorker.register(url, options); | 10 return navigator.serviceWorker.register(url, options); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 break; | 192 break; |
193 case tests[i].NOTRUN: | 193 case tests[i].NOTRUN: |
194 // Leave NOTRUN alone. It'll get marked as a NOTRUN when the test | 194 // Leave NOTRUN alone. It'll get marked as a NOTRUN when the test |
195 // terminates. | 195 // terminates. |
196 break; | 196 break; |
197 } | 197 } |
198 } | 198 } |
199 }; | 199 }; |
200 | 200 |
201 function service_worker_test(url, description) { | 201 function service_worker_test(url, description) { |
202 var scope = window.location.origin + '/service-worker-scope/' + | 202 var scope = window.location.origin + '/service-worker-scope' + |
203 window.location.pathname; | 203 window.location.pathname; |
204 | 204 |
205 var test = async_test(description); | 205 var test = async_test(description); |
206 var registration; | 206 var registration; |
207 service_worker_unregister_and_register(test, url, scope) | 207 service_worker_unregister_and_register(test, url, scope) |
208 .then(function(r) { | 208 .then(function(r) { |
209 registration = r; | 209 registration = r; |
210 return wait_for_update(test, registration); | 210 return wait_for_update(test, registration); |
211 }) | 211 }) |
212 .then(function(worker) { return fetch_tests_from_worker(worker); }) | 212 .then(function(worker) { return fetch_tests_from_worker(worker); }) |
(...skipping 26 matching lines...) Expand all Loading... |
239 HTTPS_ORIGIN: 'https://' + ORIGINAL_HOST + ':' + HTTPS_PORT, | 239 HTTPS_ORIGIN: 'https://' + ORIGINAL_HOST + ':' + HTTPS_PORT, |
240 HTTP_REMOTE_ORIGIN: 'http://' + REMOTE_HOST + ':' + HTTP_PORT, | 240 HTTP_REMOTE_ORIGIN: 'http://' + REMOTE_HOST + ':' + HTTP_PORT, |
241 HTTPS_REMOTE_ORIGIN: 'https://' + REMOTE_HOST + ':' + HTTPS_PORT, | 241 HTTPS_REMOTE_ORIGIN: 'https://' + REMOTE_HOST + ':' + HTTPS_PORT, |
242 UNAUTHENTICATED_ORIGIN: 'http://' + UNAUTHENTICATED_HOST + ':' + HTTP_PO
RT | 242 UNAUTHENTICATED_ORIGIN: 'http://' + UNAUTHENTICATED_HOST + ':' + HTTP_PO
RT |
243 }; | 243 }; |
244 } | 244 } |
245 | 245 |
246 function base_path() { | 246 function base_path() { |
247 return location.pathname.replace(/\/[^\/]*$/, '/'); | 247 return location.pathname.replace(/\/[^\/]*$/, '/'); |
248 } | 248 } |
OLD | NEW |