| 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 = new URL('./', new URL(url, window.location)) + |
| 203 'resources/service-worker-scope' + |
| 203 window.location.pathname; | 204 window.location.pathname; |
| 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); }) |
| 213 .then(function() { return registration.unregister(); }) | 213 .then(function() { return registration.unregister(); }) |
| 214 .then(function() { test.done(); }) | 214 .then(function() { test.done(); }) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 channel.port1.onmessage = test.step_func(function() { | 257 channel.port1.onmessage = test.step_func(function() { |
| 258 unload_iframe(frame).catch(function() {}); | 258 unload_iframe(frame).catch(function() {}); |
| 259 resolve(); | 259 resolve(); |
| 260 }); | 260 }); |
| 261 frame.contentWindow.postMessage( | 261 frame.contentWindow.postMessage( |
| 262 {username: username, password: password}, | 262 {username: username, password: password}, |
| 263 [channel.port2], origin); | 263 [channel.port2], origin); |
| 264 })); | 264 })); |
| 265 }); | 265 }); |
| 266 } | 266 } |
| OLD | NEW |