| 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 } |
| 249 |
| 250 function test_login(test, origin, username, password) { |
| 251 return new Promise(function(resolve, reject) { |
| 252 with_iframe( |
| 253 origin + base_path() + |
| 254 'resources/fetch-access-control-login.html') |
| 255 .then(test.step_func(function(frame) { |
| 256 var channel = new MessageChannel(); |
| 257 channel.port1.onmessage = test.step_func(function() { |
| 258 unload_iframe(frame); |
| 259 resolve(); |
| 260 }); |
| 261 frame.contentWindow.postMessage( |
| 262 {username: username, password: password}, |
| 263 [channel.port2], origin); |
| 264 })); |
| 265 }); |
| 266 } |
| OLD | NEW |