Chromium Code Reviews| Index: LayoutTests/http/tests/serviceworker/unregister-controller.html |
| diff --git a/LayoutTests/http/tests/serviceworker/unregister-controller.html b/LayoutTests/http/tests/serviceworker/unregister-controller.html |
| index 4939a3c29c4de40a316f7d25b64e380e414d5934..05672f592fd32da1da70b414b873ef39355f5708 100644 |
| --- a/LayoutTests/http/tests/serviceworker/unregister-controller.html |
| +++ b/LayoutTests/http/tests/serviceworker/unregister-controller.html |
| @@ -68,4 +68,69 @@ async_test(function(t) { |
| }) |
| .catch(unreached_rejection(t)); |
| }, 'Unregister prevents control of subsequent navigations'); |
| + |
| +async_test(function(t) { |
| + var scope = |
| + 'resources/unregister-controller-page.html?unregister-then-register'; |
| + var worker; |
| + var controller; |
| + var iframe; |
| + |
| + service_worker_unregister_and_register(t, worker_url, scope) |
| + .then(function(registered_worker) { |
| + worker = registered_worker; |
| + return wait_for_state(t, worker, 'activated'); |
| + }) |
| + .then(function() { |
| + return with_iframe(scope); |
| + }) |
| + .then(function(frame) { |
| + iframe = frame; |
| + var w = iframe.contentWindow; |
| + controller = w.navigator.serviceWorker.controller; |
| + assert_true(controller instanceof w.ServiceWorker, |
| + 'document should load with a controller'); |
| + return navigator.serviceWorker.unregister(scope); |
| + }) |
| + .then(function() { |
| + return navigator.serviceWorker.register(worker_url, { scope: scope }); |
| + }) |
| + .then(function(registered_worker) { |
| + assert_equals(registered_worker, worker, |
| + 'register should resolve to controller'); |
| + assert_equals(registered_worker.state, 'activated', |
| + 'controller should be activated'); |
| + var sawUnload = new Promise(function(resolve) { |
| + iframe.contentWindow.addEventListener('unload', function() { |
| + resolve(); |
| + }); |
| + }); |
| + iframe.src = ''; |
| + iframe.remove(); |
| + iframe = null; |
| + return sawUnload; |
| + }) |
| + .then(function() { |
| + return with_iframe(scope); |
| + }) |
| + .then(function(frame) { |
| + var w = frame.contentWindow; |
| + assert_true( |
| + w.navigator.serviceWorker.controller instanceof w.ServiceWorker, |
| + 'document should load with a controller'); |
| + // FIXME: Failing expectation. |
|
falken
2014/07/28 12:23:23
I think this would fail regardless of unregister.
falken
2014/07/28 12:24:51
Actually, my expectation was not right. The window
|
| + assert_not_equals( |
| + w.navigator.serviceWorker.controller, controller, |
| + 'controller should be the same as the previous document\'s'); |
| + return w.fetch_url('simple.txt'); |
| + }) |
| + .then(function(response) { |
| + assert_equals(response, 'intercepted by service worker', |
| + 'controller should intercept requests'); |
| + }) |
| + .then(function() { |
| + service_worker_unregister_and_done(t, scope); |
| + }) |
| + .catch(unreached_rejection(t)); |
| +}, 'Unregister is cancelable by register'); |
| </script> |