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