| 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_activated(t, registration); | 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_equals(new_registration, registration, |
| 22 'register should resolve to the same registration'); | 22 'register should resolve to the same registration'); |
| 23 assert_equals(new_registration.active, registration.active, | 23 assert_equals(new_registration.active, registration.active, |
| 24 'register should resolve to the same worker'); | 24 'register should resolve to the same worker'); |
| 25 assert_equals(new_registration.active.state, 'activated', | 25 assert_equals(new_registration.active.state, 'activated', |
| 26 'the worker should be in state "activated"'); | 26 'the worker should be in state "activated"'); |
| 27 return registration.unregister(); | 27 return registration.unregister(); |
| 28 }) | 28 }) |
| 29 .then(function() { t.done(); }) | 29 .then(function() { t.done(); }) |
| 30 .catch(unreached_rejection(t)); | 30 .catch(unreached_rejection(t)); |
| 31 }, 'Subsequent registrations resolve to the same registration object'); | 31 }, 'Subsequent registrations resolve to the same registration object'); |
| 32 | 32 |
| 33 async_test(function(t) { | 33 async_test(function(t) { |
| 34 var scope = 'resources/scope/subsequent-register-from-different-iframe'; | 34 var scope = 'resources/scope/subsequent-register-from-different-iframe'; |
| 35 var frame; | 35 var frame; |
| 36 var registration; | 36 var registration; |
| 37 | 37 |
| 38 service_worker_unregister_and_register(t, worker_url, scope) | 38 service_worker_unregister_and_register(t, worker_url, scope) |
| 39 .then(function(r) { | 39 .then(function(r) { |
| 40 registration = r; | 40 registration = r; |
| 41 return wait_for_activated(t, registration); | 41 return wait_for_state(t, r.installing, 'activated'); |
| 42 }) | 42 }) |
| 43 .then(function() { return with_iframe('out-of-scope'); }) | 43 .then(function() { return with_iframe('out-of-scope'); }) |
| 44 .then(function(f) { | 44 .then(function(f) { |
| 45 frame = f; | 45 frame = f; |
| 46 return frame.contentWindow.navigator.serviceWorker.register( | 46 return frame.contentWindow.navigator.serviceWorker.register( |
| 47 worker_url, { scope: scope }); | 47 worker_url, { scope: scope }); |
| 48 }) | 48 }) |
| 49 .then(function(new_registration) { | 49 .then(function(new_registration) { |
| 50 assert_not_equals( | 50 assert_not_equals( |
| 51 registration, new_registration, | 51 registration, new_registration, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 assert_equals(registration, registrations[0], | 105 assert_equals(registration, registrations[0], |
| 106 'register should resolve to the same registration'); | 106 'register should resolve to the same registration'); |
| 107 }); | 107 }); |
| 108 return registrations[0].unregister(); | 108 return registrations[0].unregister(); |
| 109 }) | 109 }) |
| 110 .then(function() { t.done(); }) | 110 .then(function() { t.done(); }) |
| 111 .catch(unreached_rejection(t)); | 111 .catch(unreached_rejection(t)); |
| 112 }, 'Concurrent registrations resolve to the same registration object'); | 112 }, 'Concurrent registrations resolve to the same registration object'); |
| 113 | 113 |
| 114 </script> | 114 </script> |
| OLD | NEW |