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

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

Issue 2875383002: Upstream service worker `postMessage` tests to WPT (Closed)
Patch Set: Incorporate review feedback 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.onmessage = function(e) {
2 e.waitUntil(self.clients.matchAll().then(function(clients) {
3 clients.forEach(function(client) {
4 var messageChannel = new MessageChannel();
5 messageChannel.port1.onmessage =
6 onMessageViaMessagePort.bind(null, messageChannel.port1);
7 client.postMessage(undefined, [messageChannel.port2]);
8 });
9 }));
10 };
11
12 function onMessageViaMessagePort(port, e) {
13 var message = e.data;
14 if ('value' in message) {
15 port.postMessage({ack: 'Acking value: ' + message.value});
16 } else if ('done' in message) {
17 port.postMessage({done: true});
18 }
19 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698