| Index: LayoutTests/http/tests/serviceworker/chromium/postmessage-cross-process.html
|
| diff --git a/LayoutTests/http/tests/serviceworker/chromium/postmessage-cross-process.html b/LayoutTests/http/tests/serviceworker/chromium/postmessage-cross-process.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d20366c3aa4781d892736063a04c6839f9c03515
|
| --- /dev/null
|
| +++ b/LayoutTests/http/tests/serviceworker/chromium/postmessage-cross-process.html
|
| @@ -0,0 +1,52 @@
|
| +<!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 open_url_in_new_window(url) {
|
| + 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() {
|
| + var worker = registration.active;
|
| + open_url_in_new_window(
|
| + '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>
|
|
|