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 var worker_url = 'resources/empty-worker.js'; | 6 var worker_url = 'resources/empty-worker.js'; |
7 | 7 |
8 async_test(function(t) { | 8 async_test(function(t) { |
9 var scope = 'scope/re-register-resolves-to-new-value'; | 9 var scope = 'resources/scope/re-register-resolves-to-new-value'; |
10 var iframe; | 10 var iframe; |
11 var registration; | 11 var registration; |
12 | 12 |
13 service_worker_unregister_and_register(t, worker_url, scope) | 13 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_update(t, registration); | 16 return wait_for_update(t, registration); |
17 }) | 17 }) |
18 .then(function(worker) { | 18 .then(function(worker) { |
19 return wait_for_state(t, worker, 'activated'); | 19 return wait_for_state(t, worker, 'activated'); |
20 }) | 20 }) |
21 .then(function() { | 21 .then(function() { |
22 return registration.unregister(); | 22 return registration.unregister(); |
23 }) | 23 }) |
24 .then(function() { | 24 .then(function() { |
25 return navigator.serviceWorker.register(worker_url, { scope: scope }); | 25 return navigator.serviceWorker.register(worker_url, { scope: scope }); |
26 }) | 26 }) |
27 .then(function(new_registration) { | 27 .then(function(new_registration) { |
28 assert_not_equals(registration, new_registration, | 28 assert_not_equals(registration, new_registration, |
29 'register should resolve to a new value'); | 29 'register should resolve to a new value'); |
30 service_worker_unregister_and_done(t, scope); | 30 service_worker_unregister_and_done(t, scope); |
31 }) | 31 }) |
32 .catch(unreached_rejection(t)); | 32 .catch(unreached_rejection(t)); |
33 }, 'Unregister then register resolves to a new value'); | 33 }, 'Unregister then register resolves to a new value'); |
34 | 34 |
35 async_test(function(t) { | 35 async_test(function(t) { |
36 var scope = 'scope/re-register-while-old-registration-in-use'; | 36 var scope = 'resources/scope/re-register-while-old-registration-in-use'; |
37 var registration; | 37 var registration; |
38 | 38 |
39 service_worker_unregister_and_register(t, worker_url, scope) | 39 service_worker_unregister_and_register(t, worker_url, scope) |
40 .then(function(r) { | 40 .then(function(r) { |
41 registration = r; | 41 registration = r; |
42 return wait_for_update(t, registration); | 42 return wait_for_update(t, registration); |
43 }) | 43 }) |
44 .then(function(worker) { | 44 .then(function(worker) { |
45 return wait_for_state(t, worker, 'activated'); | 45 return wait_for_state(t, worker, 'activated'); |
46 }) | 46 }) |
47 .then(function() { | 47 .then(function() { |
48 return with_iframe(scope); | 48 return with_iframe(scope); |
49 }) | 49 }) |
50 .then(function(frame) { | 50 .then(function(frame) { |
51 return registration.unregister(); | 51 return registration.unregister(); |
52 }) | 52 }) |
53 .then(function() { | 53 .then(function() { |
54 return navigator.serviceWorker.register(worker_url, { scope: scope }); | 54 return navigator.serviceWorker.register(worker_url, { scope: scope }); |
55 }) | 55 }) |
56 .then(function(new_registration) { | 56 .then(function(new_registration) { |
57 assert_equals(registration, new_registration, | 57 assert_equals(registration, new_registration, |
58 'register should resolve to the same value'); | 58 'register should resolve to the same value'); |
59 service_worker_unregister_and_done(t, scope); | 59 service_worker_unregister_and_done(t, scope); |
60 }) | 60 }) |
61 .catch(unreached_rejection(t)); | 61 .catch(unreached_rejection(t)); |
62 }, 'Unregister then register resolves to the original value if the ' + | 62 }, 'Unregister then register resolves to the original value if the ' + |
63 'registration is in use.'); | 63 'registration is in use.'); |
64 | 64 |
65 async_test(function(t) { | 65 async_test(function(t) { |
66 var scope = 'scope/re-register-does-not-affect-existing-controllee'; | 66 var scope = 'resources/scope/re-register-does-not-affect-existing-controllee
'; |
67 var iframe; | 67 var iframe; |
68 var registration; | 68 var registration; |
69 var controller; | 69 var controller; |
70 | 70 |
71 service_worker_unregister_and_register(t, worker_url, scope) | 71 service_worker_unregister_and_register(t, worker_url, scope) |
72 .then(function(r) { | 72 .then(function(r) { |
73 registration = r; | 73 registration = r; |
74 return wait_for_update(t, registration); | 74 return wait_for_update(t, registration); |
75 }) | 75 }) |
76 .then(function(worker) { | 76 .then(function(worker) { |
(...skipping 17 matching lines...) Expand all Loading... |
94 assert_equals( | 94 assert_equals( |
95 iframe.contentWindow.navigator.serviceWorker.controller, | 95 iframe.contentWindow.navigator.serviceWorker.controller, |
96 controller, | 96 controller, |
97 'the worker from the first registration is the controller'); | 97 'the worker from the first registration is the controller'); |
98 service_worker_unregister_and_done(t, scope); | 98 service_worker_unregister_and_done(t, scope); |
99 }) | 99 }) |
100 .catch(unreached_rejection(t)); | 100 .catch(unreached_rejection(t)); |
101 }, 'Unregister then register does not affect existing controllee'); | 101 }, 'Unregister then register does not affect existing controllee'); |
102 | 102 |
103 async_test(function(t) { | 103 async_test(function(t) { |
104 var scope = 'scope/resurrection'; | 104 var scope = 'resources/scope/resurrection'; |
105 var iframe; | 105 var iframe; |
106 var registration; | 106 var registration; |
107 | 107 |
108 service_worker_unregister_and_register(t, worker_url, scope) | 108 service_worker_unregister_and_register(t, worker_url, scope) |
109 .then(function(r) { | 109 .then(function(r) { |
110 registration = r; | 110 registration = r; |
111 return wait_for_update(t, registration); | 111 return wait_for_update(t, registration); |
112 }) | 112 }) |
113 .then(function(worker) { | 113 .then(function(worker) { |
114 return wait_for_state(t, worker, 'activated'); | 114 return wait_for_state(t, worker, 'activated'); |
(...skipping 18 matching lines...) Expand all Loading... |
133 // FIXME: When crbug.com/400602 is fixed, assert that controller | 133 // FIXME: When crbug.com/400602 is fixed, assert that controller |
134 // equals the original worker. | 134 // equals the original worker. |
135 assert_not_equals( | 135 assert_not_equals( |
136 frame.contentWindow.navigator.serviceWorker.controller, null, | 136 frame.contentWindow.navigator.serviceWorker.controller, null, |
137 'document should have a controller'); | 137 'document should have a controller'); |
138 service_worker_unregister_and_done(t, scope); | 138 service_worker_unregister_and_done(t, scope); |
139 }) | 139 }) |
140 .catch(unreached_rejection(t)); | 140 .catch(unreached_rejection(t)); |
141 }, 'Unregister then register resurrects the registration'); | 141 }, 'Unregister then register resurrects the registration'); |
142 </script> | 142 </script> |
OLD | NEW |