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/empty-worker.js'; | 6 var worker_url = 'resources/empty-worker.js'; |
| 7 | 7 |
| 8 async_test(function(t) { | 8 async_test(function(t) { |
| 9 var scope = 'resources/scope/re-register-resolves-to-new-value'; | 9 var scope = 'resources/scope/re-register-resolves-to-new-value'; |
| 10 var iframe; | 10 var iframe; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 .then(function(new_registration) { | 50 .then(function(new_registration) { |
| 51 assert_equals(registration, new_registration, | 51 assert_equals(registration, new_registration, |
| 52 'register should resolve to the same registration'); | 52 'register should resolve to the same registration'); |
| 53 service_worker_unregister_and_done(t, scope); | 53 service_worker_unregister_and_done(t, scope); |
| 54 }) | 54 }) |
| 55 .catch(unreached_rejection(t)); | 55 .catch(unreached_rejection(t)); |
| 56 }, 'Unregister then register resolves to the original value if the ' + | 56 }, 'Unregister then register resolves to the original value if the ' + |
| 57 'registration is in use.'); | 57 'registration is in use.'); |
| 58 | 58 |
| 59 async_test(function(t) { | 59 async_test(function(t) { |
| 60 var scope = 'resources/scope/re-register-after-reloading-iframe-' + | |
| 61 'with-old-registration-in-use'; | |
|
nhiroki
2016/04/11 05:33:13
I'm wondering if we could minimize this test.
Wha
shimazu (google)
2016/04/11 06:58:15
I checked if getRegistration returns not null befo
| |
| 62 var old_registration; | |
| 63 var new_registration; | |
| 64 var frame; | |
| 65 var service_worker; | |
| 66 service_worker_unregister_and_register(t, worker_url, scope) | |
| 67 .then(function(r) { | |
| 68 old_registration = r; | |
| 69 return wait_for_state(t, r.installing, 'activated'); | |
| 70 }) | |
| 71 .then(function() { | |
| 72 return with_iframe(scope); | |
| 73 }) | |
| 74 .then(function(f) { | |
| 75 frame = f; | |
| 76 return old_registration.unregister(); | |
| 77 }) | |
| 78 .then(function() { | |
| 79 return new Promise(function(resolve) { | |
| 80 frame.onload = resolve; | |
| 81 frame.contentWindow.location.reload(); | |
| 82 }); | |
| 83 }) | |
| 84 .then(function() { | |
| 85 return navigator.serviceWorker.register(worker_url, { scope: scope }); | |
| 86 }) | |
| 87 .then(function(new_registration) { | |
| 88 assert_not_equals(new_registration, old_registration, | |
| 89 'registration of the same scope after ' + | |
| 90 'reloading should be updated'); | |
| 91 navigator.serviceWorker.getRegistration(scope) | |
|
nhiroki
2016/04/11 05:33:13
To reduce the nest level, you can return the promi
shimazu (google)
2016/04/11 06:58:15
Thanks! Done.
| |
| 92 .then(function(r) { | |
| 93 assert_not_equals(r, old_registration, | |
| 94 'getRegistration after reloading should ' + | |
| 95 'not get the old registration before ' + | |
| 96 'reloading'); | |
| 97 assert_equals(r, new_registration, | |
| 98 'getRegistration should bring the latest ' + | |
| 99 'registration'); | |
| 100 service_worker_unregister_and_done(t, scope); | |
| 101 }); | |
| 102 }) | |
| 103 .catch(unreached_rejection(t)); | |
| 104 }, 'Unregistration followed by reloading the iframe provided by a ' + | |
| 105 'service worker should unregister successfully and new registration later ' + | |
| 106 'should be active'); | |
| 107 | |
| 108 async_test(function(t) { | |
| 60 var scope = 'resources/scope/re-register-does-not-affect-existing-controllee '; | 109 var scope = 'resources/scope/re-register-does-not-affect-existing-controllee '; |
| 61 var iframe; | 110 var iframe; |
| 62 var registration; | 111 var registration; |
| 63 var controller; | 112 var controller; |
| 64 | 113 |
| 65 service_worker_unregister_and_register(t, worker_url, scope) | 114 service_worker_unregister_and_register(t, worker_url, scope) |
| 66 .then(function(r) { | 115 .then(function(r) { |
| 67 registration = r; | 116 registration = r; |
| 68 return wait_for_state(t, r.installing, 'activated'); | 117 return wait_for_state(t, r.installing, 'activated'); |
| 69 }) | 118 }) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 // FIXME: When crbug.com/400602 is fixed, assert that controller | 168 // FIXME: When crbug.com/400602 is fixed, assert that controller |
| 120 // equals the original worker. | 169 // equals the original worker. |
| 121 assert_not_equals( | 170 assert_not_equals( |
| 122 frame.contentWindow.navigator.serviceWorker.controller, null, | 171 frame.contentWindow.navigator.serviceWorker.controller, null, |
| 123 'document should have a controller'); | 172 'document should have a controller'); |
| 124 service_worker_unregister_and_done(t, scope); | 173 service_worker_unregister_and_done(t, scope); |
| 125 }) | 174 }) |
| 126 .catch(unreached_rejection(t)); | 175 .catch(unreached_rejection(t)); |
| 127 }, 'Unregister then register resurrects the registration'); | 176 }, 'Unregister then register resurrects the registration'); |
| 128 </script> | 177 </script> |
| OLD | NEW |