OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Service Worker: postMessage to ServiceWorkerClient</title> | 2 <title>Service Worker: postMessage to ServiceWorkerClient</title> |
3 <script src="../resources/testharness.js"></script> | 3 <script src="../resources/testharness.js"></script> |
4 <script src="../resources/testharnessreport.js"></script> | 4 <script src="../resources/testharnessreport.js"></script> |
5 <script src="resources/test-helpers.js"></script> | 5 <script src="resources/test-helpers.js"></script> |
6 <script> | 6 <script> |
7 var t = async_test('postMessage MessagePorts from ServiceWorker to ServiceWorker
Client'); | 7 var t = async_test('postMessage MessagePorts from ServiceWorker to ServiceWorker
Client'); |
8 t.step(function() { | 8 t.step(function() { |
9 var scope = 'resources/blank.html' | 9 var scope = 'resources/blank.html' |
10 service_worker_unregister_and_register( | 10 service_worker_unregister_and_register( |
11 t, 'resources/postmessage-msgport-to-client-worker.js', scope) | 11 t, 'resources/postmessage-msgport-to-client-worker.js', scope) |
12 .then(function(registration) { | 12 .then(function(registration) { |
13 return wait_for_update(t, registration); | 13 return wait_for_state(t, registration.installing, 'activated'); |
14 }) | |
15 .then(function(sw) { | |
16 return wait_for_state(t, sw, 'activated'); | |
17 }) | 14 }) |
18 .then(function() { return with_iframe(scope); }) | 15 .then(function() { return with_iframe(scope); }) |
19 .then(function(frame) { | 16 .then(function(frame) { |
20 var w = frame.contentWindow; | 17 var w = frame.contentWindow; |
21 w.onmessage = t.step_func(onMessage); | 18 w.onmessage = t.step_func(onMessage); |
22 w.navigator.serviceWorker.controller.postMessage('ping'); | 19 w.navigator.serviceWorker.controller.postMessage('ping'); |
23 }) | 20 }) |
24 .catch(unreached_rejection(t)); | 21 .catch(unreached_rejection(t)); |
25 | 22 |
26 var result = []; | 23 var result = []; |
(...skipping 15 matching lines...) Expand all Loading... |
42 assert_array_equals( | 39 assert_array_equals( |
43 result, expected, | 40 result, expected, |
44 'Worker should post back expected values via MessagePort.'); | 41 'Worker should post back expected values via MessagePort.'); |
45 service_worker_unregister_and_done(t, scope); | 42 service_worker_unregister_and_done(t, scope); |
46 } else { | 43 } else { |
47 assert_unreached('Got unexpected message from ServiceWorker'); | 44 assert_unreached('Got unexpected message from ServiceWorker'); |
48 } | 45 } |
49 } | 46 } |
50 }); | 47 }); |
51 </script> | 48 </script> |
OLD | NEW |