Chromium Code Reviews| Index: chrome/test/data/push_messaging/push_test.js |
| diff --git a/chrome/test/data/push_messaging/push_test.js b/chrome/test/data/push_messaging/push_test.js |
| index be99f626758be52981619306697ee0e4d1853747..490febcfad40e27c1f4e906a49ebc3805471a7b8 100644 |
| --- a/chrome/test/data/push_messaging/push_test.js |
| +++ b/chrome/test/data/push_messaging/push_test.js |
| @@ -92,8 +92,23 @@ function removeManifest() { |
| } |
| } |
| +// TODO(xiang): Remove this function after "ready" CL landed. |
|
falken
2015/03/05 09:21:52
I'm confused, I thought *this* is the "ready" CL?
|
| +function getReadyRegistration() { |
| + return navigator.serviceWorker.getRegistration().then(function(r) { |
| + if (r.active) |
| + return r; |
| + var worker = r.waiting ? r.waiting : r.installing; |
| + return new Promise(function(resolve) { |
| + worker.onstatechange = function() { |
| + if (worker.state === 'activating') |
| + resolve(r); |
| + }; |
| + }); |
| + }); |
| +} |
| + |
| function registerPush() { |
| - navigator.serviceWorker.ready.then(function(swRegistration) { |
| + getReadyRegistration().then(function(swRegistration) { |
| var registerMethodName = |
| swRegistration.pushManager.register ? 'register' : 'subscribe'; |
| return swRegistration.pushManager[registerMethodName]() |
| @@ -106,7 +121,7 @@ function registerPush() { |
| } |
| function hasPermission() { |
| - navigator.serviceWorker.ready.then(function(swRegistration) { |
| + getReadyRegistration().then(function(swRegistration) { |
| return swRegistration.pushManager.hasPermission() |
| .then(function(permission) { |
| sendResultToTest('permission status - ' + permission); |
| @@ -138,7 +153,7 @@ function unregister() { |
| } |
| function hasRegistration() { |
| - navigator.serviceWorker.ready.then(function(swRegistration) { |
| + getReadyRegistration().then(function(swRegistration) { |
| return swRegistration.pushManager.getSubscription(); |
| }).then(function(subscription) { |
| sendResultToTest(subscription ? 'true - registered' |