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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/resources/clients-get-worker.js

Issue 2881743002: [ServiceWorker] Revise wpt tests for Client.type (Closed)
Patch Set: Revise code comments Created 3 years, 7 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
(Empty)
1 self.onfetch = function(e) {
2 if (e.request.url.indexOf('clients-get-frame.html') >= 0 ||
3 e.request.url.indexOf('clients-get-client-types') >= 0) {
4 // On navigation, the client id should be null.
5 if (e.clientId === null) {
6 e.respondWith(fetch(e.request));
7 } else {
8 e.respondWith(Response.error());
9 }
10 return;
11 }
12 e.respondWith(new Response(e.clientId));
13 };
14
15 self.onmessage = function(e) {
16 var port = e.data.port;
17 var client_ids = e.data.clientIds;
18 var message = [];
19
20 e.waitUntil(Promise.all(
21 client_ids.map(function(client_id) {
22 return self.clients.get(client_id);
23 }))
24 .then(function(clients) {
25 // No matching client for a given id or a matched client is off-origin
26 // from the service worker.
27 if (clients.length == 1 && clients[0] == undefined) {
28 port.postMessage(clients[0]);
29 } else {
30 clients.forEach(function(client) {
31 if (client instanceof Client) {
32 message.push([client.visibilityState,
33 client.focused,
34 client.url,
35 client.frameType]);
36 } else {
37 message.push(client);
38 }
39 });
40 port.postMessage(message);
41 }
42 }));
43 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698