OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Service Worker: Activation occurs after registration</title> | 2 <title>Service Worker: Activation occurs after registration</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 <body> | 6 <body> |
7 <script> | 7 <script> |
8 var t = async_test('activation occurs after registration'); | 8 var t = async_test('activation occurs after registration'); |
9 t.step(function() { | 9 t.step(function() { |
10 var scope = 'resources/blank.html'; | 10 var scope = 'resources/blank.html'; |
| 11 var registration; |
| 12 |
11 service_worker_unregister_and_register( | 13 service_worker_unregister_and_register( |
12 t, 'resources/worker-no-op.js', scope).then(t.step_func(onRegister)); | 14 t, 'resources/worker-no-op.js', scope) |
13 | 15 .then(t.step_func(function(r) { |
14 function onRegister(worker) { | 16 registration = r; |
15 assert_equals(worker.state, 'parsed', 'worker should be in the "parsed"
state upon registration'); | 17 return wait_for_update(t, registration); |
16 worker.addEventListener('statechange', t.step_func(function(event) { | 18 })) |
17 if (event.target.state == 'activated') | 19 .then(t.step_func(function(worker) { |
18 service_worker_unregister_and_done(t, scope); | 20 assert_equals(worker.state, 'parsed', 'worker should be in the "parsed
" state upon registration'); |
19 })); | 21 worker.addEventListener('statechange', t.step_func(function(event) { |
20 } | 22 if (event.target.state == 'activated') |
| 23 service_worker_unregister_and_done(t, scope); |
| 24 })); |
| 25 })) |
| 26 .catch(unreached_rejection(t)); |
21 }); | 27 }); |
22 </script> | 28 </script> |
23 </body> | 29 </body> |
OLD | NEW |