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

Side by Side Diff: third_party/WebKit/LayoutTests/broadcastchannel/resources/worker.js

Issue 2004643002: Implement BroadcastChannel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address dcheng's comments Created 4 years, 5 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 var c;
2
3 function handler(e, reply) {
4 if (e.data.ping) {
5 c.postMessage(e.data.ping);
6 return;
7 }
8 if (e.data.blob) {
9 c.postMessage({blob: new Blob(e.data.blob)});
10 }
11 c = new BroadcastChannel(e.data.channel);
12 let messages = [];
13 c.onmessage = e => {
14 messages.push(e.data);
15 if (e.data == 'done')
16 reply(messages);
17 };
18 c.postMessage('from worker');
19 }
20
21 onmessage = e => handler(e, postMessage);
22
23 onconnect = e => {
24 let port = e.ports[0];
25 port.onmessage = e => handler(e, msg => port.postMessage(msg));
26 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698