Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <html> | |
|
Peter Beverloo
2014/10/17 14:04:08
nit: <!DOCTYPE html>
| |
| 2 <head> | |
| 3 <title>Push API</title> | |
|
Peter Beverloo
2014/10/17 14:04:08
micro nit: This is not the Push API, it's a test r
| |
| 4 <script> | |
| 5 function sendResultToTest(result) { | |
| 6 console.log(result); | |
| 7 if (window.domAutomationController) { | |
| 8 domAutomationController.send('' + result); | |
| 9 } | |
| 10 } | |
| 11 | |
| 12 function sendErrorToTest(error) { | |
| 13 sendResultToTest(error.name + ' - ' + error.message); | |
| 14 } | |
| 15 | |
| 16 function registerServiceWorker() { | |
| 17 navigator.serviceWorker.register('sw.js').then(function(swRegistration) { | |
| 18 console.log(swRegistration); | |
| 19 sendResultToTest('ok'); | |
| 20 }, sendErrorToTest); | |
| 21 } | |
| 22 | |
| 23 function registerPush(senderId) { | |
| 24 navigator.serviceWorker.ready.then(function() { | |
| 25 navigator.push.register(senderId).then(function(pushRegistration) { | |
| 26 sendResultToTest(pushRegistration.pushEndpoint + ' - ' + pushRegistrat ion.pushRegistrationId); | |
| 27 }, sendErrorToTest); | |
| 28 }, sendErrorToTest); | |
| 29 } | |
| 30 </script> | |
| 31 </head> | |
| 32 <body>Push API</body> | |
| 33 </html> | |
| OLD | NEW |