OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Push API Test</title> | 4 <title>Push API Test</title> |
| 5 <link rel="manifest" href="manifest.json"> |
5 <script> | 6 <script> |
6 function sendResultToTest(result) { | 7 function sendResultToTest(result) { |
7 console.log(result); | 8 console.log(result); |
8 if (window.domAutomationController) { | 9 if (window.domAutomationController) { |
9 domAutomationController.send('' + result); | 10 domAutomationController.send('' + result); |
10 } | 11 } |
11 } | 12 } |
12 | 13 |
13 function sendErrorToTest(error) { | 14 function sendErrorToTest(error) { |
14 sendResultToTest(error.name + ' - ' + error.message); | 15 sendResultToTest(error.name + ' - ' + error.message); |
15 } | 16 } |
16 | 17 |
17 function registerServiceWorker() { | 18 function registerServiceWorker() { |
18 navigator.serviceWorker.register('service_worker.js').then(function(swRegi
stration) { | 19 navigator.serviceWorker.register('service_worker.js').then(function(swRegi
stration) { |
19 console.log(swRegistration); | 20 console.log(swRegistration); |
20 sendResultToTest('ok'); | 21 sendResultToTest('ok'); |
21 }, sendErrorToTest); | 22 }, sendErrorToTest); |
22 } | 23 } |
23 | 24 |
24 function registerPush(senderId) { | 25 function registerPush() { |
25 navigator.serviceWorker.ready.then(function() { | 26 navigator.serviceWorker.ready.then(function() { |
26 navigator.push.register(senderId).then(function(pushRegistration) { | 27 // TODO(peter): Remove the argument once Blink no longer requires it. |
| 28 navigator.push.register('DEPRECATED').then(function(pushRegistration) { |
27 sendResultToTest(pushRegistration.pushEndpoint + ' - ' + pushRegistrat
ion.pushRegistrationId); | 29 sendResultToTest(pushRegistration.pushEndpoint + ' - ' + pushRegistrat
ion.pushRegistrationId); |
28 }, sendErrorToTest); | 30 }, sendErrorToTest); |
29 }, sendErrorToTest); | 31 }, sendErrorToTest); |
30 } | 32 } |
31 </script> | 33 </script> |
32 </head> | 34 </head> |
33 <body>Push API Test</body> | 35 <body>Push API Test</body> |
34 </html> | 36 </html> |
OLD | NEW |