Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: LayoutTests/http/tests/serviceworker/unregister-then-register-new-script.html

Issue 776373003: ServiceWorker cleanup: remove wait_for_update() in favor of r.installing in most tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 = 'resources/scope/register-waits-for-unregistered-registration-to -clear'; 9 var scope = 'resources/scope/register-waits-for-unregistered-registration-to -clear';
10 var new_worker_url = worker_url + '?new'; 10 var new_worker_url = worker_url + '?new';
11 var iframe; 11 var iframe;
12 var registration; 12 var registration;
13 var unloaded = false; 13 var unloaded = false;
14 14
15 service_worker_unregister_and_register(t, worker_url, scope) 15 service_worker_unregister_and_register(t, worker_url, scope)
16 .then(function(r) { 16 .then(function(r) {
17 registration = r; 17 registration = r;
18 return wait_for_update(t, registration); 18 return wait_for_state(t, r.installing, 'activated');
19 })
20 .then(function(worker) {
21 return wait_for_state(t, worker, 'activated');
22 }) 19 })
23 .then(function() { 20 .then(function() {
24 return with_iframe(scope); 21 return with_iframe(scope);
25 }) 22 })
26 .then(function(frame) { 23 .then(function(frame) {
27 iframe = frame; 24 iframe = frame;
28 return registration.unregister(); 25 return registration.unregister();
29 }) 26 })
30 .then(function() { 27 .then(function() {
31 setTimeout(function() { 28 setTimeout(function() {
(...skipping 21 matching lines...) Expand all
53 50
54 async_test(function(t) { 51 async_test(function(t) {
55 var scope = 'resources/scope/unregister-then-register-new-script-that-exists '; 52 var scope = 'resources/scope/unregister-then-register-new-script-that-exists ';
56 var new_worker_url = worker_url + '?new'; 53 var new_worker_url = worker_url + '?new';
57 var iframe; 54 var iframe;
58 var registration; 55 var registration;
59 56
60 service_worker_unregister_and_register(t, worker_url, scope) 57 service_worker_unregister_and_register(t, worker_url, scope)
61 .then(function(r) { 58 .then(function(r) {
62 registration = r; 59 registration = r;
63 return wait_for_update(t, registration); 60 return wait_for_state(t, r.installing, 'activated');
64 })
65 .then(function(worker) {
66 return wait_for_state(t, worker, 'activated');
67 }) 61 })
68 .then(function() { 62 .then(function() {
69 return with_iframe(scope); 63 return with_iframe(scope);
70 }) 64 })
71 .then(function(frame) { 65 .then(function(frame) {
72 iframe = frame; 66 iframe = frame;
73 return registration.unregister(); 67 return registration.unregister();
74 }) 68 })
75 .then(function() { 69 .then(function() {
76 var promise = navigator.serviceWorker.register(new_worker_url, 70 var promise = navigator.serviceWorker.register(new_worker_url,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 }, 'Registering a new script URL while an unregistered registration is in use'); 112 }, 'Registering a new script URL while an unregistered registration is in use');
119 113
120 async_test(function(t) { 114 async_test(function(t) {
121 var scope = 'resources/scope/unregister-then-register-new-script-that-404s'; 115 var scope = 'resources/scope/unregister-then-register-new-script-that-404s';
122 var iframe; 116 var iframe;
123 var registration; 117 var registration;
124 118
125 service_worker_unregister_and_register(t, worker_url, scope) 119 service_worker_unregister_and_register(t, worker_url, scope)
126 .then(function(r) { 120 .then(function(r) {
127 registration = r; 121 registration = r;
128 return wait_for_update(t, registration); 122 return wait_for_state(t, r.installing, 'activated');
129 })
130 .then(function(worker) {
131 return wait_for_state(t, worker, 'activated');
132 }) 123 })
133 .then(function() { 124 .then(function() {
134 return with_iframe(scope); 125 return with_iframe(scope);
135 }) 126 })
136 .then(function(frame) { 127 .then(function(frame) {
137 iframe = frame; 128 iframe = frame;
138 return registration.unregister(); 129 return registration.unregister();
139 }) 130 })
140 .then(function() { 131 .then(function() {
141 var promise = navigator.serviceWorker.register('this-will-404', 132 var promise = navigator.serviceWorker.register('this-will-404',
(...skipping 20 matching lines...) Expand all
162 'unregistered registration'); 153 'unregistered registration');
163 154
164 async_test(function(t) { 155 async_test(function(t) {
165 var scope = 'resources/scope/unregister-then-register-reject-install-worker' ; 156 var scope = 'resources/scope/unregister-then-register-reject-install-worker' ;
166 var iframe; 157 var iframe;
167 var registration; 158 var registration;
168 159
169 service_worker_unregister_and_register(t, worker_url, scope) 160 service_worker_unregister_and_register(t, worker_url, scope)
170 .then(function(r) { 161 .then(function(r) {
171 registration = r; 162 registration = r;
172 return wait_for_update(t, registration); 163 return wait_for_state(t, r.installing, 'activated');
173 })
174 .then(function(worker) {
175 return wait_for_state(t, worker, 'activated');
176 }) 164 })
177 .then(function() { 165 .then(function() {
178 return with_iframe(scope); 166 return with_iframe(scope);
179 }) 167 })
180 .then(function(frame) { 168 .then(function(frame) {
181 iframe = frame; 169 iframe = frame;
182 return registration.unregister(); 170 return registration.unregister();
183 }) 171 })
184 .then(function() { 172 .then(function() {
185 var promise = navigator.serviceWorker.register( 173 var promise = navigator.serviceWorker.register(
186 'resources/reject-install-worker.js', { scope: scope }); 174 'resources/reject-install-worker.js', { scope: scope });
187 unload_iframe(iframe); 175 unload_iframe(iframe);
188 return promise; 176 return promise;
189 }) 177 })
190 .then(function(r) { 178 .then(function(r) {
191 registration = r; 179 registration = r;
192 return wait_for_update(t, registration); 180 return wait_for_state(t, r.installing, 'redundant');
193 })
194 .then(function(worker) {
195 return wait_for_state(t, worker, 'redundant');
196 }) 181 })
197 .then(function() { 182 .then(function() {
198 return with_iframe(scope); 183 return with_iframe(scope);
199 }) 184 })
200 .then(function(frame) { 185 .then(function(frame) {
201 assert_equals(frame.contentWindow.navigator.serviceWorker.controller, 186 assert_equals(frame.contentWindow.navigator.serviceWorker.controller,
202 null, 187 null,
203 'document should not load with a controller'); 188 'document should not load with a controller');
204 unload_iframe(frame); 189 unload_iframe(frame);
205 return registration.unregister(); 190 return registration.unregister();
206 }) 191 })
207 .then(function() { 192 .then(function() {
208 t.done(); 193 t.done();
209 }) 194 })
210 .catch(unreached_rejection(t)); 195 .catch(unreached_rejection(t));
211 }, 'Registering a new script URL that fails to install does not resurrect ' + 196 }, 'Registering a new script URL that fails to install does not resurrect ' +
212 'an unregistered registration'); 197 'an unregistered registration');
213 </script> 198 </script>
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/unregister-then-register.html ('k') | LayoutTests/http/tests/serviceworker/waiting.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698