| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <script src="../resources/testharness.js"></script> | |
| 3 <script src="../resources/testharnessreport.js"></script> | |
| 4 <script src="resources/test-helpers.js"></script> | |
| 5 <script> | |
| 6 async_test(function(t) { | |
| 7 var documentURL = 'no-such-worker'; | |
| 8 navigator.serviceWorker.getRegistration(documentURL) | |
| 9 .then(function(value) { | |
| 10 assert_equals(value, undefined, | |
| 11 'getRegistration should resolve with undefined'); | |
| 12 t.done(); | |
| 13 }) | |
| 14 .catch(unreached_rejection(t)); | |
| 15 }, 'getRegistration'); | |
| 16 | |
| 17 async_test(function(t) { | |
| 18 var scope = 'resources/scope/getregistration/normal'; | |
| 19 var registration; | |
| 20 service_worker_unregister_and_register(t, 'resources/empty-worker.js', | |
| 21 scope) | |
| 22 .then(function(r) { | |
| 23 registration = r; | |
| 24 return navigator.serviceWorker.getRegistration(scope); | |
| 25 }) | |
| 26 .then(function(value) { | |
| 27 assert_equals( | |
| 28 value, registration, | |
| 29 'getRegistration should resolve to the same registration object'); | |
| 30 service_worker_unregister_and_done(t, scope); | |
| 31 }) | |
| 32 .catch(unreached_rejection(t)); | |
| 33 }, 'Register then getRegistration'); | |
| 34 | |
| 35 async_test(function(t) { | |
| 36 var scope = 'resources/scope/getregistration/url-with-fragment'; | |
| 37 var documentURL = scope + '#ref'; | |
| 38 var registration; | |
| 39 service_worker_unregister_and_register(t, 'resources/empty-worker.js', | |
| 40 scope) | |
| 41 .then(function(r) { | |
| 42 registration = r; | |
| 43 return navigator.serviceWorker.getRegistration(documentURL); | |
| 44 }) | |
| 45 .then(function(value) { | |
| 46 assert_equals( | |
| 47 value, registration, | |
| 48 'getRegistration should resolve to the same registration object'); | |
| 49 service_worker_unregister_and_done(t, scope); | |
| 50 }) | |
| 51 .catch(unreached_rejection(t)); | |
| 52 }, 'Register then getRegistration with a URL having a fragment'); | |
| 53 | |
| 54 async_test(function(t) { | |
| 55 var documentURL = 'http://example.com/'; | |
| 56 navigator.serviceWorker.getRegistration(documentURL) | |
| 57 .then(function() { | |
| 58 assert_unreached( | |
| 59 'getRegistration with an out of origin URL should fail'); | |
| 60 }, function(reason) { | |
| 61 assert_equals( | |
| 62 reason.name, 'SecurityError', | |
| 63 'getRegistration with an out of origin URL should fail'); | |
| 64 t.done(); | |
| 65 }) | |
| 66 .catch(unreached_rejection(t)); | |
| 67 }, 'getRegistration with a cross origin URL'); | |
| 68 | |
| 69 async_test(function(t) { | |
| 70 var scope = 'resources/scope/getregistration/register-unregister'; | |
| 71 service_worker_unregister_and_register(t, 'resources/empty-worker.js', | |
| 72 scope) | |
| 73 .then(function(registration) { | |
| 74 return registration.unregister(); | |
| 75 }) | |
| 76 .then(function() { | |
| 77 return navigator.serviceWorker.getRegistration(scope); | |
| 78 }) | |
| 79 .then(function(value) { | |
| 80 assert_equals(value, undefined, | |
| 81 'getRegistration should resolve with undefined'); | |
| 82 t.done(); | |
| 83 }) | |
| 84 .catch(unreached_rejection(t)); | |
| 85 }, 'Register then Unregister then getRegistration'); | |
| 86 | |
| 87 </script> | |
| OLD | NEW |