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 2998b199f4601ff712a093575cb8d444c917d8b0..b8752f44470f5ca8f4ac140ba95164da9fbd3edf 100644 |
| --- a/chrome/test/data/push_messaging/push_test.js |
| +++ b/chrome/test/data/push_messaging/push_test.js |
| @@ -5,6 +5,7 @@ |
| 'use strict'; |
| var pushData = new FutureData(); |
| +var pushRegistration = null; |
| // Sends data back to the test. This must be in response to an earlier |
| // request, but it's ok to respond asynchronously. The request blocks until |
| @@ -91,9 +92,10 @@ function registerPush() { |
| navigator.serviceWorker.ready.then(function(swRegistration) { |
| // TODO(mvanouwerkerk): Cleanup once the final API is exposed. |
| var pushManager = swRegistration.pushManager || navigator.push; |
| - return pushManager.register().then(function(pushRegistration) { |
| - sendResultToTest(pushRegistration.pushEndpoint + ' - ' + |
| - pushRegistration.pushRegistrationId); |
| + return pushManager.register().then(function(registration) { |
| + pushRegistration = registration; |
| + sendResultToTest(registration.pushEndpoint + ' - ' + |
| + registration.pushRegistrationId); |
| }); |
| }).catch(sendErrorToTest); |
| } |
| @@ -116,6 +118,19 @@ function isControlled() { |
| } |
| } |
| +function unregister() { |
| + if (!pushRegistration) { |
| + sendErrorToTest('no registration'); |
|
Michael van Ouwerkerk
2014/12/16 12:58:41
Use sendResultToTest, there is no error object her
|
| + return; |
| + } |
| + |
| + pushRegistration.unregister().then(function(result) { |
| + sendResultToTest('unregister result: ' + result); |
| + }, function(error) { |
| + sendResultToTest('unregister error: ' + error.name + ': ' + error.message); |
| + }); |
| +} |
| + |
| addEventListener('message', function(event) { |
| var message = JSON.parse(event.data); |
| if (message.type == 'push') { |