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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/resources/clients-get-worker.js

Issue 2415873002: Import w3c tests for the service workers (Closed)
Patch Set: Rebase Created 4 years, 2 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 if (e.clientId === null) {
4 e.respondWith(fetch(e.request));
5 } else {
6 e.respondWith(Response.error());
7 }
8 return;
9 }
10 e.respondWith(new Response(e.clientId));
11 };
12
13 self.onmessage = function(e) {
14 var port = e.data.port;
15 if (e.data.message == 'get_client_ids') {
16 var clientIds = e.data.clientIds;
17 var message = [];
18
19 Promise.all(
20 clientIds.map(function(clientId) {
21 return self.clients.get(clientId);
22 }).concat(self.clients.get("invalid-id"))
23 ).then(function(clients) {
24 clients.forEach(function(client) {
25 if (client instanceof Client) {
26 message.push([client.visibilityState,
27 client.focused,
28 client.url,
29 client.frameType]);
30 } else {
31 message.push(client);
32 }
33 });
34 port.postMessage(message);
35 });
36 } else if (e.data.message == 'get_other_client_id') {
37 var clientId = e.data.clientId;
38 var message;
39
40 self.clients.get(clientId)
41 .then(function(client) {
42 if (client instanceof Client) {
43 message = [client.visibilityState,
44 client.focused,
45 client.url,
46 client.frameType];
47 } else {
48 message = client;
49 }
50 port.postMessage(message);
51 });
52 }
53 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698