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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/serviceworker/chromium/resources/postmessage-cross-process-worker.js
diff --git a/LayoutTests/http/tests/serviceworker/chromium/resources/postmessage-cross-process-worker.js b/LayoutTests/http/tests/serviceworker/chromium/resources/postmessage-cross-process-worker.js
new file mode 100644
index 0000000000000000000000000000000000000000..3b60019713b6073830a800178d2a7022ffb9d362
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/chromium/resources/postmessage-cross-process-worker.js
@@ -0,0 +1,32 @@
+var port;
+var resultport = null;
+var result = null;
+
+function send_result_if_ready() {
+ if (resultport && result) {
+ resultport.postMessage(result);
+ }
+}
+
+self.onmessage = function(e) {
+ var message = e.data;
+ if ('port' in message) {
+ port = message.port;
+ port.onmessage = on_message;
+ } else if ('done' in message) {
+ result = message.done;
+ send_result_if_ready();
+ } else if ('resultport' in message) {
+ resultport = message.resultport;
+ send_result_if_ready();
+ }
+};
+
+function on_message(e) {
+ var message = e.data;
+ if ('value' in message) {
+ port.postMessage('Acking value: ' + message.value);
+ } else if ('done' in message) {
+ port.postMessage('quit');
+ }
+}
« 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