Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(724)

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/foreign-fetch-cors-worker.js

Issue 2676733002: Upstream foreign fetch tests. (Closed)
Patch Set: rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 importScripts('../../resources/get-host-info.js'); 1 importScripts('get-host-info.sub.js');
2 var host_info = get_host_info(); 2 var host_info = get_host_info();
3 3
4 self.addEventListener('install', function(event) { 4 self.addEventListener('install', function(event) {
5 event.registerForeignFetch({scopes: [registration.scope], origins: ['*']}); 5 event.registerForeignFetch({scopes: [registration.scope], origins: ['*']});
6 }); 6 });
7 7
8 self.addEventListener('foreignfetch', function(event) { 8 self.addEventListener('foreignfetch', function(event) {
9 var response = JSON.parse(decodeURIComponent(location.search.substring(1))); 9 var response = JSON.parse(decodeURIComponent(location.search.substring(1)));
10 var url = new URL(event.request.url); 10 var url = new URL(event.request.url);
11 var params = JSON.parse(decodeURIComponent(url.search.substring(1))); 11 var params = JSON.parse(decodeURIComponent(url.search.substring(1)));
12 var url_to_fetch = 'fetch-access-control.php?'; 12 var url_to_fetch = 'fetch-access-control.py?';
13 if (params.cross_origin) { 13 if (params.cross_origin) {
14 url_to_fetch = 14 url_to_fetch =
15 host_info.HTTPS_ORIGIN + '/serviceworker/resources/' + url_to_fetch; 15 host_info.HTTPS_ORIGIN + new URL('./', location).pathname + url_to_fet ch;
16 } 16 }
17 if (params.with_aceheaders) 17 if (params.with_aceheaders)
18 url_to_fetch += 'ACEHeaders=X-ServiceWorker-ServerHeader&'; 18 url_to_fetch += 'ACEHeaders=X-ServiceWorker-ServerHeader&';
19 if (params.with_acaorigin) 19 if (params.with_acaorigin)
20 url_to_fetch += 'ACAOrigin=*'; 20 url_to_fetch += 'ACAOrigin=*';
21 fetch_params = {}; 21 fetch_params = {};
22 if (params.cross_origin && !params.with_acaorigin) 22 if (params.cross_origin && !params.with_acaorigin)
23 fetch_params.mode = 'no-cors'; 23 fetch_params.mode = 'no-cors';
24 event.respondWith(fetch(url_to_fetch, fetch_params) 24 event.respondWith(fetch(url_to_fetch, fetch_params)
25 .then(r => { 25 .then(r => {
26 response.response = r; 26 response.response = r;
27 return response; 27 return response;
28 })); 28 }));
29 return; 29 return;
30 }); 30 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698