OLD | NEW |
| 1 importScripts('../../resources/get-host-info.js'); |
| 2 var host_info = get_host_info(); |
| 3 |
1 self.addEventListener('fetch', function(event) { | 4 self.addEventListener('fetch', function(event) { |
2 var url = event.request.url; | 5 var url = event.request.url; |
3 if (url.indexOf('dummy-dir') == -1) { | 6 if (url.indexOf('dummy-dir') == -1) { |
4 return; | 7 return; |
5 } | 8 } |
6 var result = 'mode=' + event.request.mode + | 9 var result = 'mode=' + event.request.mode + |
7 ' credentials=' + event.request.credentials; | 10 ' credentials=' + event.request.credentials; |
8 if (url == 'http://127.0.0.1:8000/dummy-dir/same.html') { | 11 if (url == host_info.HTTP_ORIGIN + '/dummy-dir/same.html') { |
9 event.respondWith(new Response( | 12 event.respondWith(new Response( |
10 result + | 13 result + |
11 '<link id="same-same" rel="import" ' + | 14 '<link id="same-same" rel="import" ' + |
12 'href="http://127.0.0.1:8000/dummy-dir/same-same.html">' + | 15 'href="' + host_info.HTTP_ORIGIN + '/dummy-dir/same-same.html">' + |
13 '<link id="same-other" rel="import" ' + | 16 '<link id="same-other" rel="import" ' + |
14 ' href="http://localhost:8000/dummy-dir/same-other.html">')); | 17 ' href="' + host_info.HTTP_REMOTE_ORIGIN + |
15 } else if (url == 'http://localhost:8000/dummy-dir/other.html') { | 18 '/dummy-dir/same-other.html">')); |
| 19 } else if (url == host_info.HTTP_REMOTE_ORIGIN + '/dummy-dir/other.html') { |
16 event.respondWith(new Response( | 20 event.respondWith(new Response( |
17 result + | 21 result + |
18 '<link id="other-same" rel="import" ' + | 22 '<link id="other-same" rel="import" ' + |
19 ' href="http://127.0.0.1:8000/dummy-dir/other-same.html">' + | 23 ' href="' + host_info.HTTP_ORIGIN + '/dummy-dir/other-same.html">' + |
20 '<link id="other-other" rel="import" ' + | 24 '<link id="other-other" rel="import" ' + |
21 ' href="http://localhost:8000/dummy-dir/other-other.html">')); | 25 ' href="' + host_info.HTTP_REMOTE_ORIGIN + |
| 26 '/dummy-dir/other-other.html">')); |
22 } else { | 27 } else { |
23 event.respondWith(new Response(result)); | 28 event.respondWith(new Response(result)); |
24 } | 29 } |
25 }); | 30 }); |
OLD | NEW |