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

Side by Side Diff: chrome/test/data/push_messaging/push_test.js

Issue 930083002: Unregister with push service and SW database when permission is lost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add copy ctor Created 5 years, 10 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 'use strict'; 5 'use strict';
6 6
7 var resultQueue = new ResultQueue(); 7 var resultQueue = new ResultQueue();
8 var pushRegistration = null; 8 var pushRegistration = null;
9 9
10 // Sends data back to the test. This must be in response to an earlier 10 // Sends data back to the test. This must be in response to an earlier
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 var unregisterMethodName = 131 var unregisterMethodName =
132 pushRegistration.unregister ? 'unregister' : 'unsubscribe'; 132 pushRegistration.unregister ? 'unregister' : 'unsubscribe';
133 pushRegistration[unregisterMethodName]().then(function(result) { 133 pushRegistration[unregisterMethodName]().then(function(result) {
134 sendResultToTest('unregister result: ' + result); 134 sendResultToTest('unregister result: ' + result);
135 }, function(error) { 135 }, function(error) {
136 sendResultToTest('unregister error: ' + error.name + ': ' + error.message); 136 sendResultToTest('unregister error: ' + error.name + ': ' + error.message);
137 }); 137 });
138 } 138 }
139 139
140 function hasRegistration() {
141 navigator.serviceWorker.ready.then(function(swRegistration) {
142 return swRegistration.pushManager.getSubscription();
143 }).then(function(subscription) {
144 sendResultToTest(subscription ? 'true - registered'
145 : 'false - not registered');
146 }).catch(sendErrorToTest);
147 }
148
140 addEventListener('message', function(event) { 149 addEventListener('message', function(event) {
141 var message = JSON.parse(event.data); 150 var message = JSON.parse(event.data);
142 if (message.type == 'push') 151 if (message.type == 'push')
143 resultQueue.push(message.data); 152 resultQueue.push(message.data);
144 }, false); 153 }, false);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698