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/subsequent-register-from-same-window'; | 9 var scope = 'resources/scope/subsequent-register-from-same-window'; |
| 10 var registration; | 10 var registration; |
| 11 | 11 |
| 12 service_worker_unregister_and_register(t, worker_url, scope) | 12 service_worker_unregister_and_register(t, worker_url, scope) |
| 13 .then(function(r) { | 13 .then(function(r) { |
| 14 registration = r; | 14 registration = r; |
| 15 return wait_for_state(t, r.installing, 'activated'); | 15 return wait_for_state(t, r.installing, 'activated'); |
| 16 }) | 16 }) |
| 17 .then(function() { | 17 .then(function() { |
| 18 return navigator.serviceWorker.register(worker_url, { scope: scope }); | 18 return navigator.serviceWorker.register(worker_url, { scope: scope }); |
| 19 }) | 19 }) |
| 20 .then(function(new_registration) { | 20 .then(function(new_registration) { |
| 21 assert_equals(new_registration, registration, | 21 assert_registration_equals(new_registration, registration); |
| 22 'register should resolve to the same registration'); | 22 assert_not_equals( |
| 23 new_registration, registration, | |
| 24 'register should resolve to the new registration object'); | |
|
falken
2015/08/25 03:28:29
(sorry for grammar nit)
"the new" -> "a new"
"the
nhiroki
2015/08/25 06:28:07
Thanks! Grammar correction is really helpful :)
| |
| 23 assert_equals(new_registration.active, registration.active, | 25 assert_equals(new_registration.active, registration.active, |
| 24 'register should resolve to the same worker'); | 26 'register should resolve to the same worker'); |
| 25 assert_equals(new_registration.active.state, 'activated', | 27 assert_equals(new_registration.active.state, 'activated', |
| 26 'the worker should be in state "activated"'); | 28 'the worker should be in state "activated"'); |
| 27 return registration.unregister(); | 29 return registration.unregister(); |
| 28 }) | 30 }) |
| 29 .then(function() { t.done(); }) | 31 .then(function() { t.done(); }) |
| 30 .catch(unreached_rejection(t)); | 32 .catch(unreached_rejection(t)); |
| 31 }, 'Subsequent registrations resolve to the same registration object'); | 33 }, 'Subsequent registrations resolve to the different registration object ' + |
| 34 'but they refer to the same registration and workers'); | |
| 32 | 35 |
| 33 async_test(function(t) { | 36 async_test(function(t) { |
| 34 var scope = 'resources/scope/subsequent-register-from-different-iframe'; | 37 var scope = 'resources/scope/subsequent-register-from-different-iframe'; |
| 35 var frame; | 38 var frame; |
| 36 var registration; | 39 var registration; |
| 37 | 40 |
| 38 service_worker_unregister_and_register(t, worker_url, scope) | 41 service_worker_unregister_and_register(t, worker_url, scope) |
| 39 .then(function(r) { | 42 .then(function(r) { |
| 40 registration = r; | 43 registration = r; |
| 41 return wait_for_state(t, r.installing, 'activated'); | 44 return wait_for_state(t, r.installing, 'activated'); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 service_worker_unregister(t, scope) | 97 service_worker_unregister(t, scope) |
| 95 .then(function() { | 98 .then(function() { |
| 96 var promises = []; | 99 var promises = []; |
| 97 for (var i = 0; i < 10; ++i) { | 100 for (var i = 0; i < 10; ++i) { |
| 98 promises.push(navigator.serviceWorker.register(worker_url, | 101 promises.push(navigator.serviceWorker.register(worker_url, |
| 99 { scope: scope })); | 102 { scope: scope })); |
| 100 } | 103 } |
| 101 return Promise.all(promises); | 104 return Promise.all(promises); |
| 102 }) | 105 }) |
| 103 .then(function(registrations) { | 106 .then(function(registrations) { |
| 107 for (var i = 1; i < 10; ++i) { | |
|
falken
2015/08/25 03:28:29
can you make 10 a named variable?
nhiroki
2015/08/25 06:28:07
Done.
| |
| 108 assert_registration_equals(registrations[i], registrations[0]); | |
| 109 assert_not_equals( | |
| 110 registrations[i], registrations[0], | |
| 111 'register should resolve to the new registration object'); | |
| 112 } | |
| 104 registrations.forEach(function(registration) { | 113 registrations.forEach(function(registration) { |
| 105 assert_equals(registration, registrations[0], | |
| 106 'register should resolve to the same registration'); | |
| 107 }); | 114 }); |
| 108 return registrations[0].unregister(); | 115 return registrations[0].unregister(); |
| 109 }) | 116 }) |
| 110 .then(function() { t.done(); }) | 117 .then(function() { t.done(); }) |
| 111 .catch(unreached_rejection(t)); | 118 .catch(unreached_rejection(t)); |
| 112 }, 'Concurrent registrations resolve to the same registration object'); | 119 }, 'Concurrent registrations resolve to the different registration object ' + |
| 120 'but they refer to the same registration and workers'); | |
| 113 | 121 |
| 114 </script> | 122 </script> |
| OLD | NEW |