| 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_test(url, description) { | 3 function service_worker_test(url, description) { |
| 4 var t = async_test(description); | 4 var t = async_test(description); |
| 5 t.step(function() { | 5 t.step(function() { |
| 6 var scope = 'nonexistent'; | 6 var scope = 'nonexistent'; |
| 7 service_worker_unregister_and_register(t, url, scope).then(t.step_func(o
nRegistered)); | 7 service_worker_unregister_and_register(t, url, scope).then(t.step_func(o
nRegistered)); |
| 8 | 8 |
| 9 function onRegistered(worker) { | 9 function onRegistered(worker) { |
| 10 var messageChannel = new MessageChannel(); | 10 var messageChannel = new MessageChannel(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 resolve(frame); | 58 resolve(frame); |
| 59 }; | 59 }; |
| 60 document.body.appendChild(frame); | 60 document.body.appendChild(frame); |
| 61 }); | 61 }); |
| 62 } | 62 } |
| 63 | 63 |
| 64 function normalizeURL(url) { | 64 function normalizeURL(url) { |
| 65 return new URL(url, document.location).toString().replace(/#.*$/, ''); | 65 return new URL(url, document.location).toString().replace(/#.*$/, ''); |
| 66 } | 66 } |
| 67 |
| 68 function wait_for_state(test, worker, state) { |
| 69 return new Promise(test.step_func(function(resolve, reject) { |
| 70 worker.addEventListener('statechange', test.step_func(function() { |
| 71 if (worker.state === state) |
| 72 resolve(state); |
| 73 })); |
| 74 })); |
| 75 } |
| OLD | NEW |