Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
|
falken
2015/06/10 04:14:39
<title>
nhiroki
2015/06/10 06:47:21
Done.
| |
| 2 <script src="../resources/testharness.js"></script> | |
| 3 <script src="../resources/testharnessreport.js"></script> | |
| 4 <script src="resources/test-helpers.js"></script> | |
| 5 <script> | |
| 6 promise_test(function(t) { | |
| 7 var scope = 'resources/scope/update'; | |
| 8 var worker_url = 'resources/update-worker.php'; | |
| 9 var expected_url = normalizeURL(worker_url); | |
| 10 var registration; | |
| 11 | |
| 12 service_worker_unregister_and_register(t, worker_url, scope) | |
| 13 .then(function(r) { | |
| 14 registration = r; | |
| 15 return wait_for_state(t, registration.installing, 'activated'); | |
| 16 }) | |
| 17 .then(function() { | |
| 18 assert_equals(registration.installing, null, | |
| 19 'installing should be null in the initial state'); | |
| 20 assert_equals(registration.waiting, null, | |
| 21 'waiting should be null in the initial state'); | |
| 22 assert_equals(registration.active.scriptURL, expected_url, | |
| 23 'active should exist in the initial state'); | |
| 24 | |
| 25 // A new worker should be found. | |
| 26 registration.update(); | |
| 27 return wait_for_update(t, registration); | |
| 28 }) | |
| 29 .then(function() { | |
| 30 assert_equals(registration.installing.scriptURL, expected_url, | |
| 31 'new installing should be set after updatefound'); | |
| 32 assert_equals(registration.waiting, null, | |
| 33 'waiting should still be null after updatefound'); | |
| 34 assert_equals(registration.active.scriptURL, expected_url, | |
| 35 'active should still exist after update found'); | |
| 36 return wait_for_state(t, registration.installing, 'installed'); | |
| 37 }) | |
| 38 .then(function() { | |
| 39 assert_equals(registration.installing, null, | |
| 40 'installing should be null after installing'); | |
| 41 assert_equals(registration.waiting.scriptURL, expected_url, | |
| 42 'waiting should be set after installing'); | |
| 43 assert_equals(registration.active.scriptURL, expected_url, | |
| 44 'active should still exist after installing'); | |
| 45 return wait_for_state(t, registration.waiting, 'activated'); | |
| 46 }) | |
| 47 .then(function() { | |
| 48 assert_equals(registration.installing, null, | |
| 49 'installing should be null after activated'); | |
| 50 assert_equals(registration.waiting, null, | |
| 51 'waiting should be null after activated'); | |
| 52 assert_equals(registration.active.scriptURL, expected_url, | |
| 53 'new worker should be promoted to active'); | |
| 54 t.done(); | |
| 55 }) | |
| 56 }, 'Update a registration'); | |
| 57 </script> | |
| OLD | NEW |