| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Service Worker: postMessage to Client</title> | 2 <title>Service Worker: postMessage to Client</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 Client'); | 7 var t = async_test('postMessage MessagePorts from ServiceWorker to 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).then(t.st
ep_func(onRegister)); |
| 12 onRegister); | |
| 13 | 12 |
| 14 function onRegister(worker) { | 13 function onRegister(worker) { |
| 15 worker.addEventListener('statechange', t.step_func(function(event) { | 14 worker.addEventListener('statechange', t.step_func(function(event) { |
| 16 if (event.target.state == 'active') | 15 if (event.target.state == 'active') |
| 17 onActive(); | 16 onActive(); |
| 18 })); | 17 })); |
| 19 } | 18 } |
| 20 | 19 |
| 21 function onActive() { | 20 function onActive() { |
| 22 with_iframe(scope, t.step_func(function(frame) { | 21 with_iframe(scope, t.step_func(function(frame) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 43 result.push(message.ack); | 42 result.push(message.ack); |
| 44 } else if ('done' in message) { | 43 } else if ('done' in message) { |
| 45 assert_array_equals(result, expected, 'Worker should post back expec
ted values via MessagePort.'); | 44 assert_array_equals(result, expected, 'Worker should post back expec
ted values via MessagePort.'); |
| 46 service_worker_unregister_and_done(t, scope); | 45 service_worker_unregister_and_done(t, scope); |
| 47 } else { | 46 } else { |
| 48 assert_unreached('Got unexpected message from ServiceWorker'); | 47 assert_unreached('Got unexpected message from ServiceWorker'); |
| 49 } | 48 } |
| 50 } | 49 } |
| 51 }); | 50 }); |
| 52 </script> | 51 </script> |
| OLD | NEW |