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

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: jochen review comments 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 ed810e1bd39785e4f35d730fbe42d1b95a12ce3b..a02f3aea88cb33d0c9c3a13a5bfa8066daa1d9d1 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,7 +92,8 @@ function removeManifest() {
function registerPush() {
navigator.serviceWorker.ready.then(function(swRegistration) {
return swRegistration.pushManager.register()
- .then(function(pushRegistration) {
+ .then(function(registration) {
+ pushRegistration = registration
sendResultToTest(pushRegistration.endpoint + ' - ' +
pushRegistration.registrationId);
});
@@ -115,6 +117,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') {

Powered by Google App Engine
This is Rietveld 408576698