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

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 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 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') {

Powered by Google App Engine
This is Rietveld 408576698