| 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 <link rel="manifest" href="manifest.json"> |
| 6 <script> | 6 <script> |
| 7 var pushData = new FutureData(); | 7 var pushData = new FutureData(); |
| 8 | 8 |
| 9 // Sends data back to the test. This must be in response to an earlier | 9 // Sends data back to the test. This must be in response to an earlier |
| 10 // request, but it's ok to respond asynchronously. The request blocks until | 10 // request, but it's ok to respond asynchronously. The request blocks until |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 // Sets a new data value. If the |waiting| flag is on, it is turned off and | 41 // Sets a new data value. If the |waiting| flag is on, it is turned off and |
| 42 // the data is sent to the test. | 42 // the data is sent to the test. |
| 43 FutureData.prototype.set = function(data) { | 43 FutureData.prototype.set = function(data) { |
| 44 this.data = data; | 44 this.data = data; |
| 45 if (this.waiting) { | 45 if (this.waiting) { |
| 46 sendResultToTest(data); | 46 sendResultToTest(data); |
| 47 this.waiting = false; | 47 this.waiting = false; |
| 48 } | 48 } |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 function requestNotificationPermission() { |
| 52 Notification.requestPermission(function(permission) { |
| 53 sendResultToTest('permission status - ' + permission); |
| 54 }); |
| 55 } |
| 56 |
| 51 function registerServiceWorker() { | 57 function registerServiceWorker() { |
| 52 navigator.serviceWorker.register('service_worker.js', {scope: './'}).then( | 58 navigator.serviceWorker.register('service_worker.js', {scope: './'}).then( |
| 53 function(swRegistration) { | 59 function(swRegistration) { |
| 54 sendResultToTest('ok - service worker registered'); | 60 sendResultToTest('ok - service worker registered'); |
| 55 }, sendErrorToTest); | 61 }, sendErrorToTest); |
| 56 } | 62 } |
| 57 | 63 |
| 58 function removeManifest() { | 64 function removeManifest() { |
| 59 var element = document.querySelector('link[rel="manifest"]'); | 65 var element = document.querySelector('link[rel="manifest"]'); |
| 60 if (element) { | 66 if (element) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 86 if (message.type == 'push') { | 92 if (message.type == 'push') { |
| 87 pushData.set(message.data); | 93 pushData.set(message.data); |
| 88 } | 94 } |
| 89 }, false); | 95 }, false); |
| 90 </script> | 96 </script> |
| 91 </head> | 97 </head> |
| 92 <body> | 98 <body> |
| 93 <h1>Push API Test</h1> | 99 <h1>Push API Test</h1> |
| 94 </body> | 100 </body> |
| 95 </html> | 101 </html> |
| OLD | NEW |