Chromium Code Reviews| Index: LayoutTests/http/tests/serviceworker/postmessage-cross-process.html |
| diff --git a/LayoutTests/http/tests/serviceworker/postmessage-cross-process.html b/LayoutTests/http/tests/serviceworker/postmessage-cross-process.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a90756b98c8f044bba4a6df9c203eca294e0e39a |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/serviceworker/postmessage-cross-process.html |
| @@ -0,0 +1,53 @@ |
| +<!DOCTYPE html> |
| +<title>Service Worker: postMessage across processes</title> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="resources/test-helpers.js"></script> |
| +<script> |
| +if (window.testRunner) { |
| + testRunner.setCanOpenWindows(); |
| +} |
| + |
| +function openUrlInNewWindow(url) { |
|
falken
2014/11/20 02:29:12
In Service Worker test style <http://www.chromium.
Marijn Kruisselbrink
2014/11/20 20:41:12
Done.
Marijn Kruisselbrink
2014/11/20 20:41:12
Done.
|
| + var a = document.createElement('a'); |
| + a.href = url; |
| + // rel=noreferrer causes chrome to open the link in a new renderer process. |
| + a.setAttribute('rel', 'noreferrer'); |
| + a.target = '_blank'; |
| + a.click(); |
| +} |
| + |
| +async_test(function(t) { |
| + var scope = 'resources/simple.html'; |
| + var registration; |
| + service_worker_unregister_and_register( |
| + t, 'resources/postmessage-cross-process-worker.js', scope) |
| + .then(function(r) { |
| + registration = r; |
| + return wait_for_activated(t, registration); |
| + }) |
| + .then(function() { |
| + return get_newest_worker(registration); |
|
falken
2014/11/20 02:29:12
You can just use registration.active directly. No
Marijn Kruisselbrink
2014/11/20 20:41:12
Done.
|
| + }) |
| + .then(function(worker) { |
| + openUrlInNewWindow('resources/postmessage-cross-process-helper.html'); |
| + var messageChannel = new MessageChannel(); |
| + messageChannel.port1.onmessage = t.step_func(onMessage); |
| + worker.postMessage({resultport: messageChannel.port2}, |
| + [messageChannel.port2]); |
| + }) |
| + .catch(unreached_rejection(t)); |
| + |
| + var expected = [ |
| + 'Acking value: 1', |
| + 'Acking value: 2', |
| + ]; |
| + |
| + function onMessage(e) { |
| + var result = e.data; |
| + assert_array_equals(result, expected, |
| + 'Worker should ack values posted by new window in order.'); |
| + t.done(); |
| + } |
| + }, 'postMessage MessagePorts from client to SW in a different process'); |
| +</script> |