Index: third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/resources/fetch-event-test-worker.js |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-event-test-worker.js b/third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/resources/fetch-event-test-worker.js |
similarity index 65% |
copy from third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-event-test-worker.js |
copy to third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/resources/fetch-event-test-worker.js |
index f375c40e8e8c5a0b95be08c8435263debb56e08a..32a1b4f24970ac85981bd1795341f3cf697e246b 100644 |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-event-test-worker.js |
+++ b/third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/resources/fetch-event-test-worker.js |
@@ -11,6 +11,17 @@ function handleReferrer(event) { |
['Referrer: ' + event.request.referrer]))); |
} |
+function handleReferrerPolicy(event) { |
+ event.respondWith(new Response(new Blob( |
+ ['ReferrerPolicy: ' + event.request.referrerPolicy]))); |
+} |
+ |
+function handleReferrerFull(event) { |
+ event.respondWith(new Response(new Blob( |
+ ['Referrer: ' + event.request.referrer + '\n' + |
+ 'ReferrerPolicy: ' + event.request.referrerPolicy]))); |
+} |
+ |
function handleClientId(event) { |
var body; |
if (event.clientId !== null) { |
@@ -70,9 +81,38 @@ function handleUsedCheck(event) { |
} |
} |
-function handleHeaders(event) { |
- const headers = Array.from(event.request.headers); |
- event.respondWith(new Response(JSON.stringify(headers))); |
+function handleFragmentCheck(event) { |
+ var body; |
+ if (event.request.url.indexOf('#') === -1) { |
+ body = 'Fragment Not Found'; |
+ } else { |
+ body = 'Fragment Found'; |
+ } |
+ event.respondWith(new Response(body)); |
+} |
+ |
+function handleCache(event) { |
+ event.respondWith(new Response(event.request.cache)); |
+} |
+ |
+function handleEventSource(event) { |
+ if (event.request.mode === 'navigate') { |
+ return; |
+ } |
+ var data = { |
+ mode: event.request.mode, |
+ cache: event.request.cache, |
+ credentials: event.request.credentials |
+ }; |
+ var body = 'data:' + JSON.stringify(data) + '\n\n'; |
+ event.respondWith(new Response(body, { |
+ headers: { 'Content-Type': 'text/event-stream' } |
+ } |
+ )); |
+} |
+ |
+function handleIntegrity(event) { |
+ event.respondWith(new Response(event.request.integrity)); |
} |
self.addEventListener('fetch', function(event) { |
@@ -80,6 +120,8 @@ self.addEventListener('fetch', function(event) { |
var handlers = [ |
{ pattern: '?string', fn: handleString }, |
{ pattern: '?blob', fn: handleBlob }, |
+ { pattern: '?referrerFull', fn: handleReferrerFull }, |
+ { pattern: '?referrerPolicy', fn: handleReferrerPolicy }, |
{ pattern: '?referrer', fn: handleReferrer }, |
{ pattern: '?clientId', fn: handleClientId }, |
{ pattern: '?ignore', fn: function() {} }, |
@@ -88,7 +130,10 @@ self.addEventListener('fetch', function(event) { |
{ pattern: '?form-post', fn: handleFormPost }, |
{ pattern: '?multiple-respond-with', fn: handleMultipleRespondWith }, |
{ pattern: '?used-check', fn: handleUsedCheck }, |
- { pattern: '?headers', fn: handleHeaders } |
+ { pattern: '?fragment-check', fn: handleFragmentCheck }, |
+ { pattern: '?cache', fn: handleCache }, |
+ { pattern: '?eventsource', fn: handleEventSource }, |
+ { pattern: '?integrity', fn: handleIntegrity }, |
]; |
var handler = null; |