OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Service Worker: Registration update()</title> | 2 <title>Service Worker: Registration update()</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 promise_test(function(t) { | 7 promise_test(function(t) { |
8 var scope = 'resources/scope/update'; | 8 var scope = 'resources/scope/update'; |
9 var worker_url = 'resources/update-worker.php'; | 9 var worker_url = 'resources/update-worker.php'; |
10 var expected_url = normalizeURL(worker_url); | 10 var expected_url = normalizeURL(worker_url); |
11 var registration; | 11 var registration; |
12 | 12 |
13 return service_worker_unregister_and_register(t, worker_url, scope) | 13 return service_worker_unregister_and_register(t, worker_url, scope) |
14 .then(function(r) { | 14 .then(function(r) { |
15 registration = r; | 15 registration = r; |
16 return wait_for_state(t, registration.installing, 'activated'); | 16 return wait_for_state(t, registration.installing, 'activated'); |
17 }) | 17 }) |
18 .then(function() { | 18 .then(function() { |
19 assert_equals(registration.installing, null, | 19 assert_equals(registration.installing, null, |
20 'installing should be null in the initial state'); | 20 'installing should be null in the initial state'); |
21 assert_equals(registration.waiting, null, | 21 assert_equals(registration.waiting, null, |
22 'waiting should be null in the initial state'); | 22 'waiting should be null in the initial state'); |
23 assert_equals(registration.active.scriptURL, expected_url, | 23 assert_equals(registration.active.scriptURL, expected_url, |
24 'active should exist in the initial state'); | 24 'active should exist in the initial state'); |
25 | 25 |
26 // A new worker should be found. | 26 // A new worker should be found. |
27 registration.update(); | 27 return registration.update(); |
28 return wait_for_update(t, registration); | |
zino
2015/08/03 13:43:56
Looks good to me but would you please clarify one
jungkees
2015/08/05 02:09:31
wait_for_update() helper function is more generall
| |
29 }) | 28 }) |
30 .then(function() { | 29 .then(function() { |
31 assert_equals(registration.installing.scriptURL, expected_url, | 30 assert_equals(registration.installing.scriptURL, expected_url, |
32 'new installing should be set after updatefound'); | 31 'new installing should be set after updatefound'); |
33 assert_equals(registration.waiting, null, | 32 assert_equals(registration.waiting, null, |
34 'waiting should still be null after updatefound'); | 33 'waiting should still be null after updatefound'); |
35 assert_equals(registration.active.scriptURL, expected_url, | 34 assert_equals(registration.active.scriptURL, expected_url, |
36 'active should still exist after update found'); | 35 'active should still exist after update found'); |
37 return wait_for_state(t, registration.installing, 'installed'); | 36 return wait_for_state(t, registration.installing, 'installed'); |
38 }) | 37 }) |
(...skipping 10 matching lines...) Expand all Loading... | |
49 assert_equals(registration.installing, null, | 48 assert_equals(registration.installing, null, |
50 'installing should be null after activated'); | 49 'installing should be null after activated'); |
51 assert_equals(registration.waiting, null, | 50 assert_equals(registration.waiting, null, |
52 'waiting should be null after activated'); | 51 'waiting should be null after activated'); |
53 assert_equals(registration.active.scriptURL, expected_url, | 52 assert_equals(registration.active.scriptURL, expected_url, |
54 'new worker should be promoted to active'); | 53 'new worker should be promoted to active'); |
55 return service_worker_unregister_and_done(t, scope); | 54 return service_worker_unregister_and_done(t, scope); |
56 }) | 55 }) |
57 }, 'Update a registration'); | 56 }, 'Update a registration'); |
58 </script> | 57 </script> |
OLD | NEW |