| 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 1076f3fb99dc3a4a96c489b3daf6adb8a7e5bc23..697c0e48d4297f443eb8b3088051aa0d11ed60e8 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,8 +92,9 @@ function removeManifest() {
|
| function registerPush() {
|
| navigator.serviceWorker.ready.then(function(swRegistration) {
|
| return swRegistration.pushManager.register()
|
| - .then(function(pushRegistration) {
|
| + .then(function(registration) {
|
| // TODO: Cleanup once the final API is exposed.
|
| + pushRegistration = registration;
|
| var endpoint = pushRegistration.endpoint ||
|
| pushRegistration.pushEndpoint;
|
| var registrationId = pushRegistration.registrationId ||
|
| @@ -119,6 +121,19 @@ function isControlled() {
|
| }
|
| }
|
|
|
| +function unregister() {
|
| + if (!pushRegistration) {
|
| + sendResultToTest('unregister error: no registration');
|
| + 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') {
|
|
|