Chromium Code Reviews| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 } | 48 } |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 function registerServiceWorker() { | 51 function registerServiceWorker() { |
| 52 navigator.serviceWorker.register('service_worker.js', {scope: './'}).then( | 52 navigator.serviceWorker.register('service_worker.js', {scope: './'}).then( |
| 53 function(swRegistration) { | 53 function(swRegistration) { |
| 54 sendResultToTest('ok - service worker registered'); | 54 sendResultToTest('ok - service worker registered'); |
| 55 }, sendErrorToTest); | 55 }, sendErrorToTest); |
| 56 } | 56 } |
| 57 | 57 |
| 58 function removeManifest() { | |
| 59 var element = document.querySelector('link[rel="manifest"]'); | |
| 60 if (element) { | |
| 61 element.parentNode.removeChild(element); | |
| 62 sendResultToTest('ok'); | |
|
Michael van Ouwerkerk
2014/10/29 13:53:18
Please be more specific, it's harder to debug when
Peter Beverloo
2014/10/29 13:56:23
Done.
| |
| 63 } else | |
| 64 sendResultToTest('fail'); | |
| 65 } | |
| 66 | |
| 58 function registerPush() { | 67 function registerPush() { |
| 59 navigator.serviceWorker.ready.then(function() { | 68 navigator.serviceWorker.ready.then(function() { |
| 60 navigator.push.register().then(function(pushRegistration) { | 69 navigator.push.register().then(function(pushRegistration) { |
| 61 sendResultToTest(pushRegistration.pushEndpoint + ' - ' + | 70 sendResultToTest(pushRegistration.pushEndpoint + ' - ' + |
| 62 pushRegistration.pushRegistrationId); | 71 pushRegistration.pushRegistrationId); |
| 63 }, sendErrorToTest); | 72 }, sendErrorToTest); |
| 64 }, sendErrorToTest); | 73 }, sendErrorToTest); |
| 65 } | 74 } |
| 66 | 75 |
| 67 function isControlled() { | 76 function isControlled() { |
| 68 if (navigator.serviceWorker.controller) { | 77 if (navigator.serviceWorker.controller) { |
| 69 sendResultToTest('true - is controlled'); | 78 sendResultToTest('true - is controlled'); |
| 70 } else { | 79 } else { |
| 71 sendResultToTest('false - is not controlled'); | 80 sendResultToTest('false - is not controlled'); |
| 72 } | 81 } |
| 73 } | 82 } |
| 74 | 83 |
| 75 addEventListener('message', function(event) { | 84 addEventListener('message', function(event) { |
| 76 var message = JSON.parse(event.data); | 85 var message = JSON.parse(event.data); |
| 77 if (message.type == 'push') { | 86 if (message.type == 'push') { |
| 78 pushData.set(message.data); | 87 pushData.set(message.data); |
| 79 } | 88 } |
| 80 }, false); | 89 }, false); |
| 81 </script> | 90 </script> |
| 82 </head> | 91 </head> |
| 83 <body> | 92 <body> |
| 84 <h1>Push API Test</h1> | 93 <h1>Push API Test</h1> |
| 85 </body> | 94 </body> |
| 86 </html> | 95 </html> |
| OLD | NEW |