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

Side by Side Diff: LayoutTests/http/tests/serviceworker/chromium/resources/postmessage-cross-process-worker.js

Issue 730543005: Add a test for cross process service worker messaging. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: address comments Created 6 years, 1 month 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
« no previous file with comments | « LayoutTests/http/tests/serviceworker/chromium/resources/postmessage-cross-process-helper.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 var port;
2 var resultport = null;
3 var result = null;
4
5 function send_result_if_ready() {
6 if (resultport && result) {
7 resultport.postMessage(result);
8 }
9 }
10
11 self.onmessage = function(e) {
12 var message = e.data;
13 if ('port' in message) {
14 port = message.port;
15 port.onmessage = on_message;
16 } else if ('done' in message) {
17 result = message.done;
18 send_result_if_ready();
19 } else if ('resultport' in message) {
20 resultport = message.resultport;
21 send_result_if_ready();
22 }
23 };
24
25 function on_message(e) {
26 var message = e.data;
27 if ('value' in message) {
28 port.postMessage('Acking value: ' + message.value);
29 } else if ('done' in message) {
30 port.postMessage('quit');
31 }
32 }
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/chromium/resources/postmessage-cross-process-helper.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698