Chromium Code Reviews| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 function with_sandboxed_iframe(url, sandbox) { | 58 function with_sandboxed_iframe(url, sandbox) { |
| 59 return new Promise(function(resolve) { | 59 return new Promise(function(resolve) { |
| 60 var frame = document.createElement('iframe'); | 60 var frame = document.createElement('iframe'); |
| 61 frame.sandbox = sandbox; | 61 frame.sandbox = sandbox; |
| 62 frame.src = url; | 62 frame.src = url; |
| 63 frame.onload = function() { resolve(frame); }; | 63 frame.onload = function() { resolve(frame); }; |
| 64 document.body.appendChild(frame); | 64 document.body.appendChild(frame); |
| 65 }); | 65 }); |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Creates a new popup window, returning a Promise that resolves to its global | |
| 69 // scope. | |
| 70 var with_popup = function(url) { | |
|
nhiroki
2015/08/19 08:01:13
This looks no longer necessary.
jeremyarcher
2015/08/19 08:36:52
Done.
| |
| 71 return new Promise(function(resolve, reject) { | |
| 72 var win = window.open(url); | |
| 73 var interval = setInterval(function() { | |
| 74 if (win.location.href.startsWith("http")) { | |
| 75 clearInterval(interval); | |
| 76 setTimeout(function() { | |
| 77 resolve(win); | |
| 78 }, 10); | |
| 79 } | |
| 80 }, 20); | |
| 81 }); | |
| 82 } | |
| 83 | |
| 84 | |
| 68 function normalizeURL(url) { | 85 function normalizeURL(url) { |
| 69 return new URL(url, self.location).toString().replace(/#.*$/, ''); | 86 return new URL(url, self.location).toString().replace(/#.*$/, ''); |
| 70 } | 87 } |
| 71 | 88 |
| 72 function wait_for_update(test, registration) { | 89 function wait_for_update(test, registration) { |
| 73 if (!registration || registration.unregister == undefined) { | 90 if (!registration || registration.unregister == undefined) { |
| 74 return Promise.reject(new Error( | 91 return Promise.reject(new Error( |
| 75 'wait_for_update must be passed a ServiceWorkerRegistration')); | 92 'wait_for_update must be passed a ServiceWorkerRegistration')); |
| 76 } | 93 } |
| 77 | 94 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 } | 215 } |
| 199 | 216 |
| 200 function login_https(test) { | 217 function login_https(test) { |
| 201 return test_login(test, 'https://127.0.0.1:8443', | 218 return test_login(test, 'https://127.0.0.1:8443', |
| 202 'username1s', 'password1s', 'cookie1') | 219 'username1s', 'password1s', 'cookie1') |
| 203 .then(function() { | 220 .then(function() { |
| 204 return test_login(test, 'https://localhost:8443', | 221 return test_login(test, 'https://localhost:8443', |
| 205 'username2s', 'password2s', 'cookie2'); | 222 'username2s', 'password2s', 'cookie2'); |
| 206 }); | 223 }); |
| 207 } | 224 } |
| OLD | NEW |