OLD | NEW |
(Empty) | |
| 1 importScripts('get-host-info.sub.js'); |
| 2 |
| 3 var worker_text = 'postMessage("worker loading intercepted by service worker");
'; |
| 4 |
| 5 self.onfetch = function(event) { |
| 6 if (event.request.url.indexOf('synthesized') != -1) { |
| 7 event.respondWith(new Response(worker_text)); |
| 8 } else if (event.request.url.indexOf('same-origin') != -1) { |
| 9 event.respondWith(fetch('dummy-worker-script.py')); |
| 10 } else if (event.request.url.indexOf('cors') != -1) { |
| 11 var path = (new URL('dummy-worker-script.py', self.location)).pathname; |
| 12 var url = get_host_info()['HTTPS_REMOTE_ORIGIN'] + path; |
| 13 var mode = "no-cors"; |
| 14 if (event.request.url.indexOf('no-cors') == -1) { |
| 15 url += '?ACAOrigin=*'; |
| 16 mode = "cors"; |
| 17 } |
| 18 event.respondWith(fetch(url, { mode: mode })); |
| 19 } |
| 20 }; |
| 21 |
OLD | NEW |