Chromium Code Reviews| Index: chrome/test/data/push_messaging/test.html |
| diff --git a/chrome/test/data/push_messaging/test.html b/chrome/test/data/push_messaging/test.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..45c20a20cc96d6324aa616f733fcc91139f045c8 |
| --- /dev/null |
| +++ b/chrome/test/data/push_messaging/test.html |
| @@ -0,0 +1,33 @@ |
| +<html> |
|
Peter Beverloo
2014/10/17 14:04:08
nit: <!DOCTYPE html>
|
| + <head> |
| + <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
|
| + <script> |
| + function sendResultToTest(result) { |
| + console.log(result); |
| + if (window.domAutomationController) { |
| + domAutomationController.send('' + result); |
| + } |
| + } |
| + |
| + function sendErrorToTest(error) { |
| + sendResultToTest(error.name + ' - ' + error.message); |
| + } |
| + |
| + function registerServiceWorker() { |
| + navigator.serviceWorker.register('sw.js').then(function(swRegistration) { |
| + console.log(swRegistration); |
| + sendResultToTest('ok'); |
| + }, sendErrorToTest); |
| + } |
| + |
| + function registerPush(senderId) { |
| + navigator.serviceWorker.ready.then(function() { |
| + navigator.push.register(senderId).then(function(pushRegistration) { |
| + sendResultToTest(pushRegistration.pushEndpoint + ' - ' + pushRegistration.pushRegistrationId); |
| + }, sendErrorToTest); |
| + }, sendErrorToTest); |
| + } |
| + </script> |
| + </head> |
| + <body>Push API</body> |
| +</html> |