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 59920c222414a5b97fefb1f6be88c70afee6e1c9..46d3f9523da11ff9392e6d49a553ebb08bf7818d 100644 |
--- a/LayoutTests/http/tests/serviceworker/unregister-controller.html |
+++ b/LayoutTests/http/tests/serviceworker/unregister-controller.html |
@@ -6,91 +6,95 @@ |
var worker_url = 'resources/simple-intercept-worker.js'; |
async_test(function(t) { |
- var scope = |
- 'resources/unregister-controller-page.html?load-before-unregister'; |
- var worker; |
- var frame_window; |
- var controller; |
+ var scope = |
+ 'resources/unregister-controller-page.html?load-before-unregister'; |
+ var frame_window; |
+ var controller; |
+ var registration; |
- service_worker_unregister_and_register(t, worker_url, scope) |
- .then(function(registration) { |
- return wait_for_update(t, registration); |
- }) |
- .then(function(registered_worker) { |
- worker = registered_worker; |
- return wait_for_state(t, worker, 'activated'); |
- }) |
- .then(function() { |
- return with_iframe(scope); |
- }) |
- .then(function(frame) { |
- frame_window = frame.contentWindow; |
- controller = frame_window.navigator.serviceWorker.controller; |
- assert_true(controller instanceof frame_window.ServiceWorker, |
- 'document should load with a controller'); |
- return navigator.serviceWorker.unregister(scope); |
- }) |
- .then(function() { |
- assert_equals(frame_window.navigator.serviceWorker.controller, |
- controller, |
- 'unregistration should not modify controller'); |
- return frame_window.fetch_url('simple.txt'); |
- }) |
- .then(function(response) { |
- assert_equals(response, 'intercepted by service worker', |
- 'controller should intercept requests'); |
- t.done(); |
- }) |
- .catch(unreached_rejection(t)); |
-}, 'Unregister does not affect existing controller'); |
+ 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) { |
+ frame_window = frame.contentWindow; |
+ controller = frame_window.navigator.serviceWorker.controller; |
+ assert_true(controller instanceof frame_window.ServiceWorker, |
+ 'document should load with a controller'); |
+ return registration.unregister(); |
+ }) |
+ .then(function() { |
+ assert_equals(frame_window.navigator.serviceWorker.controller, |
+ controller, |
+ 'unregistration should not modify controller'); |
+ return frame_window.fetch_url('simple.txt'); |
+ }) |
+ .then(function(response) { |
+ assert_equals(response, 'intercepted by service worker', |
+ 'controller should intercept requests'); |
+ t.done(); |
+ }) |
+ .catch(unreached_rejection(t)); |
+ }, 'Unregister does not affect existing controller'); |
async_test(function(t) { |
- var scope = |
- 'resources/unregister-controller-page.html?load-after-unregister'; |
+ var scope = |
+ 'resources/unregister-controller-page.html?load-after-unregister'; |
+ var registration; |
- 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 navigator.serviceWorker.unregister(scope); |
- }) |
- .then(function() { |
- return with_iframe(scope); |
- }) |
- .then(function(frame) { |
- var frame_window = frame.contentWindow; |
- assert_equals(frame_window.navigator.serviceWorker.controller, null, |
- 'document should not have a controller'); |
- return frame_window.fetch_url('simple.txt'); |
- }) |
- .then(function(response) { |
- assert_equals(response, 'a simple text file\n', |
- 'requests should not be intercepted'); |
- t.done(); |
- }) |
- .catch(unreached_rejection(t)); |
-}, 'Unregister prevents control of subsequent navigations'); |
+ 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 registration.unregister(); |
+ }) |
+ .then(function() { |
+ return with_iframe(scope); |
+ }) |
+ .then(function(frame) { |
+ var frame_window = frame.contentWindow; |
+ assert_equals(frame_window.navigator.serviceWorker.controller, null, |
+ 'document should not have a controller'); |
+ return frame_window.fetch_url('simple.txt'); |
+ }) |
+ .then(function(response) { |
+ assert_equals(response, 'a simple text file\n', |
+ 'requests should not be intercepted'); |
+ t.done(); |
+ }) |
+ .catch(unreached_rejection(t)); |
+ }, 'Unregister prevents control of subsequent navigations'); |
async_test(function(t) { |
var scope = |
'scope/no-new-controllee-even-if-registration-is-still-used'; |
+ 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) { |
- return navigator.serviceWorker.unregister(scope); |
+ return registration.unregister(); |
}) |
.then(function() { |
return with_iframe(scope); |