| OLD | NEW |
| (Empty) |
| 1 // Common helper functions for foreign fetch tests. | |
| 2 | |
| 3 // Installs a service worker on a different origin. Both |worker| and |scope| | |
| 4 // are resolved relative to the /serviceworker/resources/ directory on a | |
| 5 // remote origin. | |
| 6 function install_cross_origin_worker( | |
| 7 t, worker, scope, origin = get_host_info().HTTPS_REMOTE_ORIGIN) { | |
| 8 return with_iframe(origin + | |
| 9 '/serviceworker/resources/install-worker-helper.html') | |
| 10 .then(frame => new Promise((resolve, reject) => { | |
| 11 var channel = new MessageChannel(); | |
| 12 frame.contentWindow.postMessage({worker: worker, | |
| 13 options: {scope: scope}, | |
| 14 port: channel.port1}, | |
| 15 '*', [channel.port1]); | |
| 16 channel.port2.onmessage = reply => { | |
| 17 if (reply.data == 'success') resolve(); | |
| 18 else reject(reply.data); | |
| 19 }; | |
| 20 })); | |
| 21 } | |
| OLD | NEW |