Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src="../resources/testharness.js"></script> | 2 <script src="../resources/testharness.js"></script> |
| 3 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
| 4 <script src="resources/test-helpers.js"></script> | 4 <script src="resources/test-helpers.js"></script> |
| 5 <script> | 5 <script> |
| 6 async_test(function(t) { | 6 promise_test(function(t) { |
| 7 var scope = 'resources/scope/installing-waiting-active-after-registration'; | 7 var scope = 'resources/scope/installing-waiting-active-after-registration'; |
| 8 var worker_url = 'resources/empty-worker.js'; | 8 var worker_url = 'resources/empty-worker.js'; |
| 9 var expected_url = normalizeURL(worker_url); | 9 var expected_url = normalizeURL(worker_url); |
| 10 var installing_worker; | |
| 11 var registration; | |
| 10 | 12 |
| 11 service_worker_unregister_and_register(t, worker_url, scope) | 13 return service_worker_unregister_and_register(t, worker_url, scope) |
| 12 .then(function(r) { | 14 .then(function(r) { |
| 13 registration = r; | 15 registration = r; |
|
nhiroki
2016/04/18 03:26:53
Can you add this here?
add_completion_callback(
shimazu (google)
2016/04/18 06:39:13
Done.
| |
| 16 installing_worker = registration.installing; | |
| 14 assert_equals(registration.installing.scriptURL, expected_url, | 17 assert_equals(registration.installing.scriptURL, expected_url, |
| 15 'installing before updatefound'); | 18 'installing before updatefound'); |
| 16 assert_equals(registration.waiting, null, | 19 assert_equals(registration.waiting, null, |
| 17 'waiting before updatefound'); | 20 'waiting before updatefound'); |
| 18 assert_equals(registration.active, null, | 21 assert_equals(registration.active, null, |
| 19 'active before updatefound'); | 22 'active before updatefound'); |
| 20 return wait_for_update(t, registration); | 23 return wait_for_update(t, registration); |
| 21 }) | 24 }) |
| 22 .then(function(worker) { | 25 .then(function() { |
| 23 assert_equals(registration.installing.scriptURL, expected_url, | 26 assert_equals(registration.installing, installing_worker, |
| 24 'installing after updatefound'); | 27 'installing after updatefound'); |
| 25 assert_equals(registration.waiting, null, | 28 assert_equals(registration.waiting, null, |
| 26 'waiting after updatefound'); | 29 'waiting after updatefound'); |
| 27 assert_equals(registration.active, null, | 30 assert_equals(registration.active, null, |
| 28 'active after updatefound'); | 31 'active after updatefound'); |
| 29 return wait_for_state(t, registration.installing, 'installed'); | 32 return wait_for_state(t, registration.installing, 'installed'); |
| 30 }) | 33 }) |
| 31 .then(function() { | 34 .then(function() { |
| 32 assert_equals(registration.installing, null, | 35 assert_equals(registration.installing, null, |
| 33 'installing after installed'); | 36 'installing after installed'); |
| 34 assert_equals(registration.waiting.scriptURL, expected_url, | 37 assert_equals(registration.waiting, installing_worker, |
| 35 'waiting after installed'); | 38 'waiting after installed'); |
| 36 assert_equals(registration.active, null, | 39 assert_equals(registration.active, null, |
| 37 'active after installed'); | 40 'active after installed'); |
| 38 return wait_for_state(t, registration.waiting, 'activated'); | 41 return wait_for_state(t, registration.waiting, 'activated'); |
| 39 }) | 42 }) |
| 40 .then(function() { | 43 .then(function() { |
| 41 assert_equals(registration.installing, null, | 44 assert_equals(registration.installing, null, |
| 42 'installing after activated'); | 45 'installing after activated'); |
| 43 assert_equals(registration.waiting, null, | 46 assert_equals(registration.waiting, null, |
| 44 'waiting after activated'); | 47 'waiting after activated'); |
| 45 assert_equals(registration.active.scriptURL, expected_url, | 48 assert_equals(registration.active, installing_worker, |
| 46 'active after activated'); | 49 'active after activated'); |
| 47 return Promise.all([ | 50 return Promise.all([ |
| 48 wait_for_state(t, registration.active, 'redundant'), | 51 wait_for_state(t, registration.active, 'redundant'), |
| 49 registration.unregister() | 52 registration.unregister() |
| 50 ]); | 53 ]); |
| 51 }) | 54 }) |
| 52 .then(function() { | 55 .then(function() { |
| 53 assert_equals(registration.installing, null, | 56 assert_equals(registration.installing, null, |
| 54 'installing after redundant'); | 57 'installing after redundant'); |
| 55 assert_equals(registration.waiting, null, | 58 assert_equals(registration.waiting, null, |
| 56 'waiting after redundant'); | 59 'waiting after redundant'); |
| 57 // According to spec, Clear Registration runs Update State which is | 60 // According to spec, Clear Registration runs Update State which is |
| 58 // immediately followed by setting active to null, which means by the | 61 // immediately followed by setting active to null, which means by the |
| 59 // time the event loop turns and the Promise for statechange is | 62 // time the event loop turns and the Promise for statechange is |
| 60 // resolved, this will be gone. | 63 // resolved, this will be gone. |
| 61 assert_equals(registration.active, null, | 64 assert_equals(registration.active, null, |
| 62 'active should be null after redundant'); | 65 'active should be null after redundant'); |
| 63 t.done(); | 66 }); |
| 64 }) | |
| 65 .catch(unreached_rejection(t)); | |
| 66 }, 'installing/waiting/active after registration'); | 67 }, 'installing/waiting/active after registration'); |
| 67 </script> | 68 </script> |
| OLD | NEW |