Chromium Code Reviews| OLD | NEW | 
|---|---|
| 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/simple-intercept-worker.js'; | 6 var worker_url = 'resources/simple-intercept-worker.js'; | 
| 7 | 7 | 
| 8 async_test(function(t) { | 8 async_test(function(t) { | 
| 9 var scope = | 9 var scope = | 
| 10 'resources/unregister-controller-page.html?load-before-unregister'; | 10 'resources/unregister-controller-page.html?load-before-unregister'; | 
| 11 var worker; | 11 var worker; | 
| 12 var frame_window; | 12 var frame_window; | 
| 13 var controller; | 13 var controller; | 
| 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(registration) { | |
| 17 return wait_for_update(t, registration); | |
| 18 }) | |
| 16 .then(function(registered_worker) { | 19 .then(function(registered_worker) { | 
| 17 worker = registered_worker; | 20 worker = registered_worker; | 
| 18 return wait_for_state(t, worker, 'activated'); | 21 return wait_for_state(t, worker, 'activated'); | 
| 19 }) | 22 }) | 
| 20 .then(function() { | 23 .then(function() { | 
| 21 return with_iframe(scope); | 24 return with_iframe(scope); | 
| 22 }) | 25 }) | 
| 23 .then(function(frame) { | 26 .then(function(frame) { | 
| 24 frame_window = frame.contentWindow; | 27 frame_window = frame.contentWindow; | 
| 25 controller = frame_window.navigator.serviceWorker.controller; | 28 controller = frame_window.navigator.serviceWorker.controller; | 
| 26 assert_true(controller instanceof frame_window.ServiceWorker, | 29 assert_true(controller instanceof frame_window.ServiceWorker, | 
| 27 'document should load with a controller'); | 30 'document should load with a controller'); | 
| 28 return navigator.serviceWorker.unregister(scope); | 31 return navigator.serviceWorker.unregister(scope); | 
| 29 }) | 32 }) | 
| 30 .then(function() { | 33 .then(function() { | 
| 31 assert_equals(frame_window.navigator.serviceWorker.controller, | 34 assert_equals(frame_window.navigator.serviceWorker.controller, | 
| 32 controller, | 35 controller, | 
| 33 'unregistration should not modify controller'); | 36 'unregistration should not modify controller'); | 
| 34 return frame_window.fetch_url('simple.txt'); | 37 return frame_window.fetch_url('simple.txt'); | 
| 35 }) | 38 }) | 
| 36 .then(function(response) { | 39 .then(function(response) { | 
| 37 assert_equals(response, 'intercepted by service worker', | 40 assert_equals(response, 'intercepted by service worker', | 
| 38 'controller should intercept requests'); | 41 'controller should intercept requests'); | 
| 39 t.done(); | 42 t.done(); | 
| 40 }) | 43 }) | 
| 41 .catch(unreached_rejection(t)); | 44 .catch(unreached_rejection(t)); | 
| 42 }, 'Unregister does not affect existing controller'); | 45 }, 'Unregister does not affect existing controller'); | 
| 43 | 46 | 
| 44 async_test(function(t) { | 47 async_test(function(t) { | 
| 45 var scope = | 48 var scope = | 
| 46 'resources/unregister-controller-page.html?load-after-unregister'; | 49 'resources/unregister-controller-page.html?load-after-unregister'; | 
| 47 | 50 | 
| 48 service_worker_unregister_and_register(t, worker_url, scope) | 51 service_worker_unregister_and_register(t, worker_url, scope) | 
| 52 .then(function(registration) { | |
| 53 return wait_for_update(t, registration); | |
| 54 }) | |
| 49 .then(function(worker) { | 55 .then(function(worker) { | 
| 50 return wait_for_state(t, worker, 'activated'); | 56 return wait_for_state(t, worker, 'activated'); | 
| 51 }) | 57 }) | 
| 52 .then(function() { | 58 .then(function() { | 
| 53 return navigator.serviceWorker.unregister(scope); | 59 return navigator.serviceWorker.unregister(scope); | 
| 54 }) | 60 }) | 
| 55 .then(function() { | 61 .then(function() { | 
| 56 return with_iframe(scope); | 62 return with_iframe(scope); | 
| 57 }) | 63 }) | 
| 58 .then(function(frame) { | 64 .then(function(frame) { | 
| 59 var frame_window = frame.contentWindow; | 65 var frame_window = frame.contentWindow; | 
| 60 assert_equals(frame_window.navigator.serviceWorker.controller, null, | 66 assert_equals(frame_window.navigator.serviceWorker.controller, null, | 
| 61 'document should not have a controller'); | 67 'document should not have a controller'); | 
| 62 return frame_window.fetch_url('simple.txt'); | 68 return frame_window.fetch_url('simple.txt'); | 
| 63 }) | 69 }) | 
| 64 .then(function(response) { | 70 .then(function(response) { | 
| 65 assert_equals(response, 'a simple text file\n', | 71 assert_equals(response, 'a simple text file\n', | 
| 66 'requests should not be intercepted'); | 72 'requests should not be intercepted'); | 
| 67 t.done(); | 73 t.done(); | 
| 68 }) | 74 }) | 
| 69 .catch(unreached_rejection(t)); | 75 .catch(unreached_rejection(t)); | 
| 70 }, 'Unregister prevents control of subsequent navigations'); | 76 }, 'Unregister prevents control of subsequent navigations'); | 
| 71 | |
| 72 async_test(function(t) { | |
| 
 
falken
2014/08/14 10:16:37
Why is this removed?
 
nhiroki
2014/08/14 13:22:07
Maybe wrongly removed. Recalled.
 
 | |
| 73 var scope = | |
| 74 'scope/no-new-controllee-even-if-registration-is-still-used'; | |
| 75 | |
| 76 service_worker_unregister_and_register(t, worker_url, scope) | |
| 77 .then(function(registered_worker) { | |
| 78 return wait_for_state(t, registered_worker, 'activated'); | |
| 79 }) | |
| 80 .then(function() { | |
| 81 return with_iframe(scope); | |
| 82 }) | |
| 83 .then(function(frame) { | |
| 84 return navigator.serviceWorker.unregister(scope); | |
| 85 }) | |
| 86 .then(function() { | |
| 87 return with_iframe(scope); | |
| 88 }) | |
| 89 .then(function(frame) { | |
| 90 assert_equals(frame.contentWindow.navigator.serviceWorker.controller, | |
| 91 null, | |
| 92 'document should not have a controller'); | |
| 93 t.done(); | |
| 94 }) | |
| 95 .catch(unreached_rejection(t)); | |
| 96 }, 'Unregister prevents new controllee even if registration is still in use'); | |
| 97 </script> | 77 </script> | 
| OLD | NEW |