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

Side by Side Diff: LayoutTests/http/tests/serviceworker/chromium/postmessage-cross-process.html

Issue 730543005: Add a test for cross process service worker messaging. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: address comments 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 unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/chromium/resources/postmessage-cross-process-helper.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
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>
6 <script>
7 if (window.testRunner) {
8 testRunner.setCanOpenWindows();
9 }
10
11 function open_url_in_new_window(url) {
12 var a = document.createElement('a');
13 a.href = url;
14 // rel=noreferrer causes chrome to open the link in a new renderer process.
15 a.setAttribute('rel', 'noreferrer');
16 a.target = '_blank';
17 a.click();
18 }
19
20 async_test(function(t) {
21 var scope = 'resources/simple.html';
22 var registration;
23 service_worker_unregister_and_register(
24 t, 'resources/postmessage-cross-process-worker.js', scope)
25 .then(function(r) {
26 registration = r;
27 return wait_for_activated(t, registration);
28 })
29 .then(function() {
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]);
37 })
38 .catch(unreached_rejection(t));
39
40 var expected = [
41 'Acking value: 1',
42 'Acking value: 2',
43 ];
44
45 function onMessage(e) {
46 var result = e.data;
47 assert_array_equals(result, expected,
48 'Worker should ack values posted by new window in order.');
49 t.done();
50 }
51 }, 'postMessage MessagePorts from client to SW in a different process');
52 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/chromium/resources/postmessage-cross-process-helper.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698