| Index: LayoutTests/http/tests/serviceworker/unregister-then-register-new-script.html
|
| diff --git a/LayoutTests/http/tests/serviceworker/unregister-then-register-new-script.html b/LayoutTests/http/tests/serviceworker/unregister-then-register-new-script.html
|
| index baf22ff77fe961dc5f99caaacf9961bafd55719f..7cf9a3a88558273d333ced65d123fb47e2eacbe0 100644
|
| --- a/LayoutTests/http/tests/serviceworker/unregister-then-register-new-script.html
|
| +++ b/LayoutTests/http/tests/serviceworker/unregister-then-register-new-script.html
|
| @@ -6,10 +6,11 @@
|
| var worker_url = 'resources/empty-worker.js';
|
|
|
| async_test(function(t) {
|
| - var scope = 'scope/new-worker';
|
| + var scope = 'scope/register-waits-for-unregistered-registration-to-clear';
|
| var new_worker_url = worker_url + '?new';
|
| var iframe;
|
| var registration;
|
| + var unloaded = false;
|
|
|
| service_worker_unregister_and_register(t, worker_url, scope)
|
| .then(function(r) {
|
| @@ -27,14 +28,76 @@ async_test(function(t) {
|
| return registration.unregister();
|
| })
|
| .then(function() {
|
| - // FIXME: Register should not resolve until controllees are unloaded.
|
| + setTimeout(function() {
|
| + unloaded = true;
|
| + unload_iframe(iframe);
|
| + }, 10);
|
| return navigator.serviceWorker.register(new_worker_url,
|
| { scope: scope });
|
| })
|
| .then(function(new_registration) {
|
| - return wait_for_update(t, new_registration);
|
| + assert_true(unloaded,
|
| + 'register should not resolve until iframe unloaded');
|
| + assert_equals(registration.installing, null,
|
| + 'registration.installing');
|
| + assert_equals(registration.waiting, null, 'registration.waiting');
|
| + assert_equals(registration.active, null, 'registration.active');
|
| + return new_registration.unregister();
|
| + })
|
| + .then(function() {
|
| + t.done();
|
| + })
|
| + .catch(unreached_rejection(t));
|
| + }, 'Registering a new script URL does not resolve until unregistered ' +
|
| + 'registration is cleared');
|
| +
|
| +async_test(function(t) {
|
| + var scope = 'scope/unregister-then-register-new-script';
|
| + var new_worker_url = worker_url + '?new';
|
| + var iframe;
|
| + var registration;
|
| +
|
| + service_worker_unregister_and_register(t, worker_url, scope)
|
| + .then(function(r) {
|
| + registration = r;
|
| + 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 registration.unregister();
|
| + })
|
| + .then(function() {
|
| + var promise = navigator.serviceWorker.register(new_worker_url,
|
| + { scope: scope });
|
| + unload_iframe(iframe);
|
| + return promise;
|
| + })
|
| + .then(function(new_registration) {
|
| + assert_not_equals(registration, new_registration,
|
| + 'register() should resolve to a new registration');
|
| + assert_equals(registration.installing, null,
|
| + 'old registration.installing');
|
| + assert_equals(registration.waiting, null,
|
| + 'old registration.waiting');
|
| + assert_equals(registration.active, null,
|
| + 'old registration.active');
|
| + registration = new_registration;
|
| + return wait_for_update(t, registration);
|
| })
|
| .then(function(worker) {
|
| + assert_equals(registration.installing.scriptURL,
|
| + normalizeURL(new_worker_url),
|
| + 'new registration.installing');
|
| + assert_equals(registration.waiting, null,
|
| + 'new registration.waiting');
|
| + assert_equals(registration.active, null,
|
| + 'new registration.active');
|
| return wait_for_state(t, worker, 'activated');
|
| })
|
| .then(function() {
|
| @@ -44,14 +107,18 @@ async_test(function(t) {
|
| 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);
|
| + 'the new worker should control a new document');
|
| + unload_iframe(frame);
|
| + return registration.unregister();
|
| + })
|
| + .then(function() {
|
| + t.done();
|
| })
|
| .catch(unreached_rejection(t));
|
| -}, 'Unregister then register a new script URL');
|
| +}, 'Registering a new script URL while an unregistered registration is in use');
|
|
|
| async_test(function(t) {
|
| - var scope = 'scope/non-existent-worker';
|
| + var scope = 'scope/unregister-then-register-new-script-that-404s';
|
| var iframe;
|
| var registration;
|
|
|
| @@ -71,32 +138,31 @@ async_test(function(t) {
|
| return registration.unregister();
|
| })
|
| .then(function() {
|
| - // FIXME: Register should not resolve until controllees are unloaded.
|
| - return navigator.serviceWorker.register('this-will-404',
|
| - { scope: scope });
|
| + var promise = navigator.serviceWorker.register('this-will-404',
|
| + { scope: scope });
|
| + unload_iframe(iframe);
|
| + return promise;
|
| })
|
| .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);
|
| + unload_iframe(frame);
|
| + t.done();
|
| })
|
| .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 scope = 'scope/unregister-then-register-reject-install-worker';
|
| var iframe;
|
| var registration;
|
|
|
| @@ -116,19 +182,18 @@ async_test(function(t) {
|
| return registration.unregister();
|
| })
|
| .then(function() {
|
| - // FIXME: Register should not resolve until controllees are unloaded.
|
| - return navigator.serviceWorker.register(
|
| + var promise = navigator.serviceWorker.register(
|
| 'resources/reject-install-worker.js', { scope: scope });
|
| + unload_iframe(iframe);
|
| + return promise;
|
| })
|
| - .then(function(new_registration) {
|
| - return wait_for_update(t, new_registration);
|
| + .then(function(r) {
|
| + registration = r;
|
| + 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);
|
| })
|
| @@ -136,7 +201,11 @@ async_test(function(t) {
|
| assert_equals(frame.contentWindow.navigator.serviceWorker.controller,
|
| null,
|
| 'document should not load with a controller');
|
| - service_worker_unregister_and_done(t, scope);
|
| + unload_iframe(frame);
|
| + return registration.unregister();
|
| + })
|
| + .then(function() {
|
| + t.done();
|
| })
|
| .catch(unreached_rejection(t));
|
| }, 'Registering a new script URL that fails to install does not resurrect ' +
|
|
|