Chromium Code Reviews| Index: LayoutTests/http/tests/serviceworker/postmessage-to-client.html |
| diff --git a/LayoutTests/http/tests/serviceworker/postmessage-to-client.html b/LayoutTests/http/tests/serviceworker/postmessage-to-client.html |
| index 236905ba76cd5a6a24df73d08c973353838f3670..acd3a9aa4556abee26843e5a3e0c951b605bd9fa 100644 |
| --- a/LayoutTests/http/tests/serviceworker/postmessage-to-client.html |
| +++ b/LayoutTests/http/tests/serviceworker/postmessage-to-client.html |
| @@ -4,38 +4,36 @@ |
| <script src="../resources/testharnessreport.js"></script> |
| <script src="resources/test-helpers.js"></script> |
| <script> |
| -var t = async_test('postMessage from ServiceWorker to Client'); |
| -t.step(function() { |
| - var scope = 'resources/blank.html' |
| +async_test(function(t) { |
| + var scope = 'resources/blank.html'; |
| service_worker_unregister_and_register( |
| - t, 'resources/postmessage-to-client-worker.js', scope).then(t.step_func(onRegister)); |
| - |
| - function onRegister(worker) { |
| - worker.addEventListener('statechange', t.step_func(function(event) { |
| - if (event.target.state == 'activated') |
| - onActive(); |
| - })); |
| - } |
| - |
| - function onActive() { |
| - with_iframe(scope, t.step_func(function(frame) { |
| - var w = frame.contentWindow; |
| - w.onmessage = t.step_func(onMessage); |
| - w.navigator.serviceWorker.controller.postMessage('ping'); |
| - })); |
| - } |
| + t, 'resources/postmessage-to-client-worker.js', scope) |
|
falken
2014/08/14 14:23:15
indent
nhiroki
2014/08/14 16:37:53
Done.
|
| + .then(function(registration) { |
| + return wait_for_update(t, registration); |
| + }) |
| + .then(function(sw) { |
| + return wait_for_state(t, sw, 'activated'); |
| + }) |
| + .then(function() { return with_iframe(scope); }) |
| + .then(function(frame) { |
| + var w = frame.contentWindow; |
| + w.onmessage = t.step_func(onMessage); |
| + w.navigator.serviceWorker.controller.postMessage('ping'); |
| + }) |
| + .catch(unreached_rejection(t)); |
| var result = []; |
| var expected = ['Sending message via clients']; |
| function onMessage(e) { |
| - var message = e.data; |
| - if (message === 'quit') { |
| - assert_array_equals(result, expected, 'Worker should post back expected messages.'); |
| - service_worker_unregister_and_done(t, scope); |
| - } else { |
| - result.push(message); |
| - } |
| + var message = e.data; |
| + if (message === 'quit') { |
| + assert_array_equals(result, expected, |
| + 'Worker should post back expected messages.'); |
| + service_worker_unregister_and_done(t, scope); |
| + } else { |
| + result.push(message); |
| + } |
| } |
| -}); |
| + }, 'postMessage from ServiceWorker to Client'); |
| </script> |