Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Unified Diff: chrome/test/data/push_messaging/push_test.js

Issue 793403002: Implement WebPushProvider.unregister() in Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mvan_2
Patch Set: review commetns Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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') {

Powered by Google App Engine
This is Rietveld 408576698