Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 var resultQueue = new ResultQueue(); | 7 var resultQueue = new ResultQueue(); |
| 8 var pushRegistration = null; | 8 var pushRegistration = null; |
| 9 | 9 |
| 10 // Sends data back to the test. This must be in response to an earlier | 10 // Sends data back to the test. This must be in response to an earlier |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 | 130 |
| 131 var unregisterMethodName = | 131 var unregisterMethodName = |
| 132 pushRegistration.unregister ? 'unregister' : 'unsubscribe'; | 132 pushRegistration.unregister ? 'unregister' : 'unsubscribe'; |
| 133 pushRegistration[unregisterMethodName]().then(function(result) { | 133 pushRegistration[unregisterMethodName]().then(function(result) { |
| 134 sendResultToTest('unregister result: ' + result); | 134 sendResultToTest('unregister result: ' + result); |
| 135 }, function(error) { | 135 }, function(error) { |
| 136 sendResultToTest('unregister error: ' + error.name + ': ' + error.message); | 136 sendResultToTest('unregister error: ' + error.name + ': ' + error.message); |
| 137 }); | 137 }); |
| 138 } | 138 } |
| 139 | 139 |
| 140 function hasRegistration() { | |
| 141 navigator.serviceWorker.ready.then(function(swRegistration) { | |
| 142 return swRegistration.pushManager.getSubscription(); | |
| 143 }).then(function(subscription) { | |
| 144 subscription ? sendResultToTest('true - registered') | |
|
johnme
2015/02/16 20:27:45
sendResultToTest(subscription ? 'true - registered
mlamouri (slow - plz ping)
2015/02/16 20:46:03
Done.
| |
| 145 : sendResultToTest('false - not registered'); | |
| 146 }).catch(sendErrorToTest); | |
| 147 } | |
| 148 | |
| 140 addEventListener('message', function(event) { | 149 addEventListener('message', function(event) { |
| 141 var message = JSON.parse(event.data); | 150 var message = JSON.parse(event.data); |
| 142 if (message.type == 'push') | 151 if (message.type == 'push') |
| 143 resultQueue.push(message.data); | 152 resultQueue.push(message.data); |
| 144 }, false); | 153 }, false); |
| OLD | NEW |