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

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

Issue 729923004: Add some tests to make sure message ports properly queue up message. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cross_process_messaging_with_terminate
Patch Set: fix FIXMEs Created 6 years 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-port-worker.js ('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
1 var port; 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 2
11 self.onmessage = function(e) { 3 self.onmessage = function(e) {
12 var message = e.data; 4 var message = e.data;
13 if ('port' in message) { 5 if ('port' in message) {
14 port = message.port; 6 port = message.port;
15 port.onmessage = on_message; 7 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 } 8 }
23 }; 9 };
24 10
25 function on_message(e) { 11 function on_message(e) {
26 var message = e.data; 12 var message = e.data;
27 if ('value' in message) { 13 if ('value' in message) {
28 port.postMessage('Acking value: ' + message.value); 14 port.postMessage('Acking value: ' + message.value);
29 } else if ('done' in message) { 15 } else if ('done' in message) {
30 port.postMessage('quit'); 16 port.postMessage('quit');
31 } 17 }
32 } 18 }
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/chromium/resources/postmessage-port-worker.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698