Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <title>register() succeeds when permission is granted and fulfills with a valid registration</title> | |
|
Peter Beverloo
2014/12/10 00:18:18
nit: s/fulfills/resolves/ (In the test's descripti
Michael van Ouwerkerk
2014/12/10 15:13:06
Done.
| |
| 5 <link rel="manifest" href="resources/push_manifest.json"> | |
| 6 <script src="../resources/testharness.js"></script> | |
| 7 <script src="../resources/testharnessreport.js"></script> | |
| 8 <script src="../serviceworker/resources/test-helpers.js"></script> | |
| 9 </head> | |
| 10 <body> | |
| 11 <script> | |
| 12 async_test(function(test) { | |
| 13 assert_true(!!window.testRunner, 'This test requires the TestRunner.'); | |
| 14 var workerUrl = 'resources/empty_worker.js'; | |
| 15 var workerScope = 'resources/scope/' + location.pathname; | |
| 16 var swRegistration; | |
| 17 service_worker_unregister_and_register(test, workerUrl, workerScope) | |
| 18 .then(function(serviceWorkerRegistration) { | |
| 19 swRegistration = serviceWorkerRegistration; | |
| 20 return wait_for_activated(test, swRegistration); | |
| 21 }) | |
| 22 .then(function() { | |
| 23 testRunner.setPushMessagingPermission(location.origin, true); | |
| 24 return swRegistration.pushManager.register(); | |
| 25 }) | |
| 26 .then(function(pushRegistration) { | |
| 27 assert_own_property(pushRegistration, 'pushRegistrationId'); | |
| 28 assert_equals(typeof pushRegistration.pushRegistrationId, 'string'); | |
| 29 | |
| 30 assert_own_property(pushRegistration, 'pushEndpoint'); | |
| 31 assert_equals(typeof pushRegistration.pushEndpoint, 'string'); | |
| 32 try { | |
| 33 var endpointUrl = new URL(pushRegistration.pushEndpoint); | |
| 34 } catch(e) { | |
| 35 assert_unreached('Constructing a URL from the endpoint should not throw.'); | |
| 36 } | |
| 37 | |
| 38 return service_worker_unregister_and_done(test, workerScope); | |
| 39 }) | |
| 40 .catch(unreached_rejection(test)); | |
| 41 }, 'register() succeeds when permission is granted and fulfills with a valid reg istration'); | |
| 42 </script> | |
| 43 </body> | |
| 44 </html> | |
| OLD | NEW |