Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/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/http/tests/serviceworker/resources/fetch-event-test-worker.js |
index fbcc66fbcc86f4c5a73772fd49dab6d3abe3ec94..1443681f41b470e832a4898c6fdf5732ccbe3fa7 100644 |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-event-test-worker.js |
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-event-test-worker.js |
@@ -11,6 +11,16 @@ function handleReferrer(event) { |
['Referrer: ' + event.request.referrer]))); |
} |
+function handleClientId(event) { |
+ var body; |
+ if (event.clientId !== null) { |
+ body = 'Client ID Found: ' + event.clientId; |
+ } else { |
+ body = 'Client ID Not Found'; |
+ } |
+ event.respondWith(new Response(body)); |
+} |
+ |
function handleNullBody(event) { |
event.respondWith(new Response()); |
} |
@@ -23,18 +33,23 @@ function handleFormPost(event) { |
event.respondWith(new Promise(function(resolve) { |
event.request.text() |
.then(function(result) { |
- resolve(new Response(event.request.method + ':' + result)); |
+ resolve(new Response(event.request.method + ':' + |
+ event.request.headers.get('Content-Type') + ':' + |
+ result)); |
}); |
})); |
} |
-var logForMultipleRespondWith = ''; |
- |
function handleMultipleRespondWith(event) { |
+ var logForMultipleRespondWith = ''; |
for (var i = 0; i < 3; ++i) { |
logForMultipleRespondWith += '(' + i + ')'; |
try { |
- event.respondWith(new Response(logForMultipleRespondWith)); |
+ event.respondWith(new Promise(function(resolve) { |
+ setTimeout(function() { |
+ resolve(new Response(logForMultipleRespondWith)); |
+ }, 0); |
+ })); |
} catch (e) { |
logForMultipleRespondWith += '[' + e.name + ']'; |
} |
@@ -61,6 +76,7 @@ self.addEventListener('fetch', function(event) { |
{ pattern: '?string', fn: handleString }, |
{ pattern: '?blob', fn: handleBlob }, |
{ pattern: '?referrer', fn: handleReferrer }, |
+ { pattern: '?clientId', fn: handleClientId }, |
{ pattern: '?ignore', fn: function() {} }, |
{ pattern: '?null', fn: handleNullBody }, |
{ pattern: '?fetch', fn: handleFetch }, |