Chromium Code Reviews| Index: LayoutTests/http/tests/serviceworker/unregister-then-register.html |
| diff --git a/LayoutTests/http/tests/serviceworker/unregister-then-register.html b/LayoutTests/http/tests/serviceworker/unregister-then-register.html |
| index c15e86a04c29168976fe7f97ef497e39135dd7c1..a0a80f7ecf19ff723eadd03b969d507ddf230d42 100644 |
| --- a/LayoutTests/http/tests/serviceworker/unregister-then-register.html |
| +++ b/LayoutTests/http/tests/serviceworker/unregister-then-register.html |
| @@ -8,24 +8,24 @@ var worker_url = 'resources/empty-worker.js'; |
| async_test(function(t) { |
| var scope = 'scope/re-register-resolves-to-new-value'; |
| var iframe; |
| - var previous_registration; |
| + var registration; |
| service_worker_unregister_and_register(t, worker_url, scope) |
| - .then(function(registration) { |
| - previous_registration = registration; |
| + .then(function(r) { |
| + registration = r; |
| return wait_for_update(t, registration); |
| }) |
| .then(function(worker) { |
| return wait_for_state(t, worker, 'activated'); |
| }) |
| .then(function() { |
| - return navigator.serviceWorker.unregister(scope); |
| + return registration.unregister(); |
| }) |
| .then(function() { |
| return navigator.serviceWorker.register(worker_url, { scope: scope }); |
| }) |
| - .then(function(registration) { |
| - assert_not_equals(previous_registration, registration, |
| + .then(function(new_registration) { |
| + assert_not_equals(registration, new_registration, |
| 'register should resolve to a new value'); |
| service_worker_unregister_and_done(t, scope); |
| }) |
| @@ -34,11 +34,11 @@ async_test(function(t) { |
| async_test(function(t) { |
| var scope = 'scope/re-register-while-old-registration-in-use'; |
| - var previous_registration; |
| + var registration; |
| service_worker_unregister_and_register(t, worker_url, scope) |
| - .then(function(registration) { |
| - previous_registration = registration; |
| + .then(function(r) { |
| + registration = r; |
| return wait_for_update(t, registration); |
| }) |
| .then(function(worker) { |
| @@ -48,13 +48,13 @@ async_test(function(t) { |
| return with_iframe(scope); |
| }) |
| .then(function(frame) { |
| - return navigator.serviceWorker.unregister(scope); |
| + return registration.unregister(scope); |
|
nhiroki
2014/08/15 09:53:40
ditto.
|
| }) |
| .then(function() { |
| return navigator.serviceWorker.register(worker_url, { scope: scope }); |
| }) |
| - .then(function(registration) { |
| - assert_equals(previous_registration, registration, |
| + .then(function(new_registration) { |
| + assert_equals(registration, new_registration, |
| 'register should resolve to the same value'); |
| service_worker_unregister_and_done(t, scope); |
| }) |
| @@ -65,21 +65,24 @@ async_test(function(t) { |
| async_test(function(t) { |
| var scope = 'scope/re-register-does-not-affect-existing-controllee'; |
| var iframe; |
| + var registration; |
| + var controller; |
| service_worker_unregister_and_register(t, worker_url, scope) |
| - .then(function(registration) { |
| + .then(function(r) { |
| + registration = r; |
| return wait_for_update(t, registration); |
| }) |
| - .then(function(registered_worker) { |
| - return wait_for_state(t, registered_worker, 'activated'); |
| + .then(function(worker) { |
| + return wait_for_state(t, worker, 'activated'); |
| }) |
| .then(function() { |
| return with_iframe(scope); |
| }) |
| .then(function(frame) { |
| iframe = frame; |
| - worker = iframe.contentWindow.navigator.serviceWorker.controller; |
| - return navigator.serviceWorker.unregister(scope); |
| + controller = iframe.contentWindow.navigator.serviceWorker.controller; |
| + return registration.unregister(scope); |
|
nhiroki
2014/08/15 09:53:40
ditto.
|
| }) |
| .then(function() { |
| return navigator.serviceWorker.register(worker_url, { scope: scope }); |
| @@ -89,7 +92,8 @@ async_test(function(t) { |
| 'installing version is null'); |
| assert_equals(registration.waiting, null, 'waiting version is null'); |
| assert_equals( |
| - iframe.contentWindow.navigator.serviceWorker.controller, worker, |
| + iframe.contentWindow.navigator.serviceWorker.controller, |
| + controller, |
| 'the worker from the first registration is the controller'); |
| service_worker_unregister_and_done(t, scope); |
| }) |
| @@ -99,27 +103,27 @@ async_test(function(t) { |
| async_test(function(t) { |
| var scope = 'scope/resurrection'; |
| var iframe; |
| - var worker; |
| + var registration; |
| service_worker_unregister_and_register(t, worker_url, scope) |
| - .then(function(registration) { |
| + .then(function(r) { |
| + registration = r; |
| return wait_for_update(t, registration); |
| }) |
| - .then(function(registered_worker) { |
| - return wait_for_state(t, registered_worker, 'activated'); |
| + .then(function(worker) { |
| + return wait_for_state(t, worker, 'activated'); |
| }) |
| .then(function() { |
| return with_iframe(scope); |
| }) |
| .then(function(frame) { |
| iframe = frame; |
| - worker = iframe.contentWindow.navigator.serviceWorker.controller; |
| - return navigator.serviceWorker.unregister(scope); |
| + return registration.unregister(scope); |
|
nhiroki
2014/08/15 09:53:40
ditto.
|
| }) |
| .then(function() { |
| return navigator.serviceWorker.register(worker_url, { scope: scope }); |
| }) |
| - .then(function(registered_worker) { |
| + .then(function() { |
| return unload_iframe(iframe); |
| }) |
| .then(function() { |
| @@ -135,134 +139,4 @@ async_test(function(t) { |
| }) |
| .catch(unreached_rejection(t)); |
| }, 'Unregister then register resurrects the registration'); |
| - |
| -async_test(function(t) { |
| - var scope = 'scope/new-worker'; |
| - var new_worker_url = worker_url + '?new'; |
| - var iframe; |
| - |
| - service_worker_unregister_and_register(t, worker_url, scope) |
| - .then(function(registration) { |
| - return wait_for_update(t, registration); |
| - }) |
| - .then(function(worker) { |
| - return wait_for_state(t, worker, 'activated'); |
| - }) |
| - .then(function() { |
| - return with_iframe(scope); |
| - }) |
| - .then(function(frame) { |
| - iframe = frame; |
| - return navigator.serviceWorker.unregister(scope); |
| - }) |
| - .then(function() { |
| - // FIXME: Register should not resolve until controllees are unloaded. |
| - return navigator.serviceWorker.register(new_worker_url, |
| - { scope: scope }); |
| - }) |
| - .then(function(registration) { |
| - return wait_for_update(t, registration); |
| - }) |
| - .then(function(worker) { |
| - return wait_for_state(t, worker, 'activated'); |
| - }) |
| - .then(function() { |
| - return with_iframe(scope); |
| - }) |
| - .then(function(frame) { |
| - assert_equals(frame.contentWindow.navigator.serviceWorker.controller.scriptURL, |
| - normalizeURL(new_worker_url), |
| - 'document controller is the new worker'); |
| - service_worker_unregister_and_done(t, scope); |
| - }) |
| - .catch(unreached_rejection(t)); |
| -}, 'Unregister then register a new script URL'); |
| - |
| -async_test(function(t) { |
| - var scope = 'scope/non-existent-worker'; |
| - var iframe; |
| - |
| - service_worker_unregister_and_register(t, worker_url, scope) |
| - .then(function(registration) { |
| - return wait_for_update(t, registration); |
| - }) |
| - .then(function(worker) { |
| - return wait_for_state(t, worker, 'activated'); |
| - }) |
| - .then(function() { |
| - return with_iframe(scope); |
| - }) |
| - .then(function(frame) { |
| - iframe = frame; |
| - return navigator.serviceWorker.unregister(scope); |
| - }) |
| - .then(function() { |
| - // FIXME: Register should not resolve until controllees are unloaded. |
| - return navigator.serviceWorker.register('this-will-404', |
| - { scope: scope }); |
| - }) |
| - .then( |
| - function() { |
| - assert_unreached('register should reject the promise'); |
| - }, |
| - function() { |
| - return unload_iframe(iframe); |
| - }) |
| - .then(function() { |
| - return with_iframe(scope); |
| - }) |
| - .then(function(frame) { |
| - assert_equals(frame.contentWindow.navigator.serviceWorker.controller, |
| - null, |
| - 'document should not load with a controller'); |
| - service_worker_unregister_and_done(t, scope); |
| - }) |
| - .catch(unreached_rejection(t)); |
| -}, 'Registering a new script URL that 404s does not resurrect an ' + |
| - 'unregistered registration'); |
| - |
| -async_test(function(t) { |
| - var scope = 'scope/reject-install-worker'; |
| - var iframe; |
| - |
| - service_worker_unregister_and_register(t, worker_url, scope) |
| - .then(function(registration) { |
| - return wait_for_update(t, registration); |
| - }) |
| - .then(function(worker) { |
| - return wait_for_state(t, worker, 'activated'); |
| - }) |
| - .then(function() { |
| - return with_iframe(scope); |
| - }) |
| - .then(function(frame) { |
| - iframe = frame; |
| - return navigator.serviceWorker.unregister(); |
| - }) |
| - .then(function() { |
| - // FIXME: Register should not resolve until controllees are unloaded. |
| - return navigator.serviceWorker.register( |
| - 'resources/reject-install-worker.js', { scope: scope }); |
| - }) |
| - .then(function(registration) { |
| - return wait_for_update(t, registration); |
| - }) |
| - .then(function(worker) { |
| - return wait_for_state(t, worker, 'redundant'); |
| - }) |
| - .then(function(worker) { |
| - return unload_iframe(iframe); |
| - }) |
| - .then(function() { |
| - return with_iframe(scope); |
| - }) |
| - .then(function(frame) { |
| - assert_equals(frame.contentWindow.navigator.serviceWorker.controller, |
| - null, |
| - 'document should not load with a controller'); |
| - service_worker_unregister_and_done(t, scope); |
| - }) |
| - .catch(unreached_rejection(t)); |
| - }, 'Registering a new script URL that fails to install does not resurrect ' + |
| - 'an unregistered registration'); |
| </script> |