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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-event-test-worker.js

Issue 1597383002: Service Worker: (Re-commit) Add FetchEvent.clientId (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
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 },

Powered by Google App Engine
This is Rietveld 408576698