Index: LayoutTests/http/tests/serviceworker/resources/postmessage-cross-process-helper.html |
diff --git a/LayoutTests/http/tests/serviceworker/resources/postmessage-cross-process-helper.html b/LayoutTests/http/tests/serviceworker/resources/postmessage-cross-process-helper.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b4cff8054d59fee417ffb4c8d17092b4d9e145a7 |
--- /dev/null |
+++ b/LayoutTests/http/tests/serviceworker/resources/postmessage-cross-process-helper.html |
@@ -0,0 +1,36 @@ |
+<!DOCTYPE html> |
+<script src="test-helpers.js"></script> |
+<script> |
+if (window.testRunner) { |
+ // waitUntilDone here is necesary to make sure content_shell doesn't exist as |
falken
2014/11/20 02:29:13
some typos here: "necesary"->"necessary", "exist"-
Marijn Kruisselbrink
2014/11/20 20:41:13
Done.
|
+ // soon as this file is loaded. |
+ testRunner.waitUntilDone(); |
+} |
+ |
+var worker; |
+ |
+navigator.serviceWorker.getRegistration('simple.html') |
+ .then(function(registration) { |
+ return get_newest_worker(registration); |
falken
2014/11/20 02:29:12
Since we open this file after the worker activated
Marijn Kruisselbrink
2014/11/20 20:41:12
Done.
|
+ }) |
+ .then(function(sw) { |
+ worker = sw; |
+ var messageChannel = new MessageChannel(); |
+ messageChannel.port1.onmessage = onMessage; |
+ sw.postMessage({port: messageChannel.port2}, [messageChannel.port2]); |
+ messageChannel.port1.postMessage({value: 1}); |
+ messageChannel.port1.postMessage({value: 2}); |
+ messageChannel.port1.postMessage({done: true}); |
+ }); |
+ |
+var result = []; |
+ |
+function onMessage(e) { |
falken
2014/11/20 02:29:13
on_message
Marijn Kruisselbrink
2014/11/20 20:41:13
Done.
|
+ var message = e.data; |
+ if (message === 'quit') { |
+ worker.postMessage({done: result}); |
+ } else { |
+ result.push(message); |
+ } |
+}; |
falken
2014/11/20 02:29:12
no semi-colon needed here
Marijn Kruisselbrink
2014/11/20 20:41:13
Done.
|
+</script> |