2 <title>Service Worker: postMessage across processes
</title>
3 <script src=
"../../resources/testharness.js"></script>
4 <script src=
"../../resources/testharnessreport.js"></script>
5 <script src=
"../resources/test-helpers.js"></script>
7 if (window
.testRunner
) {
8 testRunner
.setCanOpenWindows();
11 function open_url_in_new_window(url
) {
12 var a
= document
.createElement('a');
14 // rel=noreferrer causes chrome to open the link in a new renderer process.
15 a
.setAttribute('rel', 'noreferrer');
20 async_test(function(t
) {
21 var scope
= 'resources/simple.html';
23 service_worker_unregister_and_register(
24 t
, 'resources/postmessage-cross-process-worker.js', scope
)
27 return wait_for_state(t
, r
.installing
, 'activated');
30 var worker
= registration
.active
;
31 open_url_in_new_window(
32 'resources/postmessage-cross-process-helper.html');
33 var messageChannel
= new MessageChannel();
34 messageChannel
.port1
.onmessage
= t
.step_func(onMessage
);
35 worker
.postMessage({resultport
: messageChannel
.port2
},
36 [messageChannel
.port2
]);
38 .catch(unreached_rejection(t
));
45 function onMessage(e
) {
47 assert_array_equals(result
, expected
,
48 'Worker should ack values posted by new window in order.');
51 }, 'postMessage MessagePorts from client to SW in a different process');