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

Unified Diff: LayoutTests/http/tests/serviceworker/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: 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
Index: LayoutTests/http/tests/serviceworker/resources/postmessage-cross-process-worker.js
diff --git a/LayoutTests/http/tests/serviceworker/resources/postmessage-cross-process-worker.js b/LayoutTests/http/tests/serviceworker/resources/postmessage-cross-process-worker.js
new file mode 100644
index 0000000000000000000000000000000000000000..12cea5ba55e87d130438c4a6aa5b7d9ad4f386d9
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/resources/postmessage-cross-process-worker.js
@@ -0,0 +1,30 @@
+var port;
+var resultport = null;
+var result = null;
+
+self.onmessage = function(e) {
+ var message = e.data;
+ if ('port' in message) {
+ port = message.port;
+ port.onmessage = onMessage;
+ } else if ('done' in message) {
+ result = message.done;
+ if (resultport) {
+ resultport.postMessage(result);
+ }
+ } else if ('resultport' in message) {
+ resultport = message.resultport;
+ if (result) {
+ resultport.postMessage(result);
+ }
+ }
+};
+
+function onMessage(e) {
+ var message = e.data;
+ if ('value' in message) {
+ port.postMessage('Acking value: ' + message.value);
+ } else if ('done' in message) {
+ port.postMessage('quit');
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698