OLD | NEW |
1 // This worker is designed to expose information about clients that is only avai
lable from Service Worker contexts. | 1 // This worker is designed to expose information about clients that is only avai
lable from Service Worker contexts. |
2 // | 2 // |
3 // In the case of the `onfetch` handler, it provides the `clientId` property of | 3 // In the case of the `onfetch` handler, it provides the `clientId` property of |
4 // the `event` object. In the case of the `onmessage` handler, it provides the | 4 // the `event` object. In the case of the `onmessage` handler, it provides the |
5 // Client instance attributes of the requested clients. | 5 // Client instance attributes of the requested clients. |
6 self.onfetch = function(e) { | 6 self.onfetch = function(e) { |
7 if (e.request.mode === 'navigate' && e.clientId !== null) { | 7 if (e.request.mode === 'navigate' && e.clientId !== null) { |
8 e.respondWith(Response.error( | 8 e.respondWith(Response.error( |
9 '`clientId` incorrectly set to non-null value for request with mode `navig
ate`' | 9 '`clientId` incorrectly set to non-null value for request with mode `navig
ate`' |
10 )); | 10 )); |
(...skipping 19 matching lines...) Expand all Loading... |
30 // No matching client for a given id or a matched client is off-origin | 30 // No matching client for a given id or a matched client is off-origin |
31 // from the service worker. | 31 // from the service worker. |
32 if (clients.length == 1 && clients[0] == undefined) { | 32 if (clients.length == 1 && clients[0] == undefined) { |
33 port.postMessage(clients[0]); | 33 port.postMessage(clients[0]); |
34 } else { | 34 } else { |
35 clients.forEach(function(client) { | 35 clients.forEach(function(client) { |
36 if (client instanceof Client) { | 36 if (client instanceof Client) { |
37 message.push([client.visibilityState, | 37 message.push([client.visibilityState, |
38 client.focused, | 38 client.focused, |
39 client.url, | 39 client.url, |
| 40 client.type, |
40 client.frameType]); | 41 client.frameType]); |
41 } else { | 42 } else { |
42 message.push(client); | 43 message.push(client); |
43 } | 44 } |
44 }); | 45 }); |
45 port.postMessage(message); | 46 port.postMessage(message); |
46 } | 47 } |
47 })); | 48 })); |
48 }; | 49 }; |
OLD | NEW |