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

Side by Side Diff: LayoutTests/http/tests/serviceworker/resources/postmessage-msgport-to-client-worker.js

Issue 1056973003: Revert of Revert of ServiceWorker: Remove Clients.getAll() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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
1 self.onmessage = function(e) { 1 self.onmessage = function(e) {
2 self.clients.getAll().then(function(clients) { 2 self.clients.matchAll().then(function(clients) {
3 clients.forEach(function(client) { 3 clients.forEach(function(client) {
4 var messageChannel = new MessageChannel(); 4 var messageChannel = new MessageChannel();
5 messageChannel.port1.onmessage = 5 messageChannel.port1.onmessage =
6 onMessageViaMessagePort.bind(null, client); 6 onMessageViaMessagePort.bind(null, client);
7 client.postMessage({port: messageChannel.port2}, 7 client.postMessage({port: messageChannel.port2},
8 [messageChannel.port2]); 8 [messageChannel.port2]);
9 }); 9 });
10 }); 10 });
11 }; 11 };
12 12
13 function onMessageViaMessagePort(client, e) { 13 function onMessageViaMessagePort(client, e) {
14 var message = e.data; 14 var message = e.data;
15 if ('value' in message) { 15 if ('value' in message) {
16 client.postMessage({ack: 'Acking value: ' + message.value}); 16 client.postMessage({ack: 'Acking value: ' + message.value});
17 } else if ('done' in message) { 17 } else if ('done' in message) {
18 client.postMessage({done: true}); 18 client.postMessage({done: true});
19 } 19 }
20 } 20 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698