| 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 async_test(function(t) { | 6 async_test(function(t) { |
| 7 var documentURL = 'no-such-worker'; | 7 var documentURL = 'no-such-worker'; |
| 8 navigator.serviceWorker.getRegistration(documentURL) | 8 navigator.serviceWorker.getRegistration(documentURL) |
| 9 .then(function(value) { | 9 .then(function(value) { |
| 10 assert_equals(value, undefined, | 10 assert_equals(value, undefined, |
| 11 'getRegistration should resolve with undefined'); | 11 'getRegistration should resolve with undefined'); |
| 12 t.done(); | 12 t.done(); |
| 13 }) | 13 }) |
| 14 .catch(unreached_rejection(t)); | 14 .catch(unreached_rejection(t)); |
| 15 }, 'getRegistration'); | 15 }, 'getRegistration'); |
| 16 | 16 |
| 17 async_test(function(t) { | 17 async_test(function(t) { |
| 18 var scope = 'resources/scope/getregistration/normal'; | 18 var scope = 'resources/scope/getregistration/normal'; |
| 19 var registration; | 19 var registration; |
| 20 service_worker_unregister_and_register(t, 'resources/empty-worker.js', | 20 service_worker_unregister_and_register(t, 'resources/empty-worker.js', |
| 21 scope) | 21 scope) |
| 22 .then(function(r) { | 22 .then(function(r) { |
| 23 registration = r; | 23 registration = r; |
| 24 return navigator.serviceWorker.getRegistration(scope); | 24 return navigator.serviceWorker.getRegistration(scope); |
| 25 }) | 25 }) |
| 26 .then(function(value) { | 26 .then(function(value) { |
| 27 assert_equals(value, registration, | 27 assert_registration_equals(value, registration); |
| 28 'getRegistration should resolve with registration'); | 28 assert_not_equals( |
| 29 value, registration, |
| 30 'getRegistration should resolve to a new registration object'); |
| 29 service_worker_unregister_and_done(t, scope); | 31 service_worker_unregister_and_done(t, scope); |
| 30 }) | 32 }) |
| 31 .catch(unreached_rejection(t)); | 33 .catch(unreached_rejection(t)); |
| 32 }, 'Register then getRegistration'); | 34 }, 'Register then getRegistration'); |
| 33 | 35 |
| 34 async_test(function(t) { | 36 async_test(function(t) { |
| 35 var scope = 'resources/scope/getregistration/url-with-fragment'; | 37 var scope = 'resources/scope/getregistration/url-with-fragment'; |
| 36 var documentURL = scope + '#ref'; | 38 var documentURL = scope + '#ref'; |
| 37 var registration; | 39 var registration; |
| 38 service_worker_unregister_and_register(t, 'resources/empty-worker.js', | 40 service_worker_unregister_and_register(t, 'resources/empty-worker.js', |
| 39 scope) | 41 scope) |
| 40 .then(function(r) { | 42 .then(function(r) { |
| 41 registration = r; | 43 registration = r; |
| 42 return navigator.serviceWorker.getRegistration(documentURL); | 44 return navigator.serviceWorker.getRegistration(documentURL); |
| 43 }) | 45 }) |
| 44 .then(function(value) { | 46 .then(function(value) { |
| 45 assert_equals(value, registration, | 47 assert_registration_equals(value, registration); |
| 46 'getRegistration should resolve with registration'); | |
| 47 service_worker_unregister_and_done(t, scope); | 48 service_worker_unregister_and_done(t, scope); |
| 48 }) | 49 }) |
| 49 .catch(unreached_rejection(t)); | 50 .catch(unreached_rejection(t)); |
| 50 }, 'Register then getRegistration with a URL having a fragment'); | 51 }, 'Register then getRegistration with a URL having a fragment'); |
| 51 | 52 |
| 52 async_test(function(t) { | 53 async_test(function(t) { |
| 53 var documentURL = 'http://example.com/'; | 54 var documentURL = 'http://example.com/'; |
| 54 navigator.serviceWorker.getRegistration(documentURL) | 55 navigator.serviceWorker.getRegistration(documentURL) |
| 55 .then(function() { | 56 .then(function() { |
| 56 assert_unreached( | 57 assert_unreached( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 76 }) | 77 }) |
| 77 .then(function(value) { | 78 .then(function(value) { |
| 78 assert_equals(value, undefined, | 79 assert_equals(value, undefined, |
| 79 'getRegistration should resolve with undefined'); | 80 'getRegistration should resolve with undefined'); |
| 80 t.done(); | 81 t.done(); |
| 81 }) | 82 }) |
| 82 .catch(unreached_rejection(t)); | 83 .catch(unreached_rejection(t)); |
| 83 }, 'Register then Unregister then getRegistration'); | 84 }, 'Register then Unregister then getRegistration'); |
| 84 | 85 |
| 85 </script> | 86 </script> |
| OLD | NEW |