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

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

Issue 2518043002: Handle push resubscribes with no sender info (avoids DCHECK) (Closed)
Patch Set: Created 4 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 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 // The ResultQueue is a mechanism for passing messages back to the test 7 // The ResultQueue is a mechanism for passing messages back to the test
8 // framework. 8 // framework.
9 var resultQueue = new ResultQueue(); 9 var resultQueue = new ResultQueue();
10 10
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 }).catch(sendErrorToTest); 132 }).catch(sendErrorToTest);
133 } 133 }
134 134
135 function workerSubscribePush() { 135 function workerSubscribePush() {
136 // Send the message to the worker for it to subscribe 136 // Send the message to the worker for it to subscribe
137 navigator.serviceWorker.controller.postMessage({command: 'workerSubscribe'}); 137 navigator.serviceWorker.controller.postMessage({command: 'workerSubscribe'});
138 } 138 }
139 139
140 function workerSubscribePushNoKey() { 140 function workerSubscribePushNoKey() {
141 // The worker will try to subscribe without providing a key. This should 141 // The worker will try to subscribe without providing a key. This should
142 // succeed if the worker was previously subscribed and fail otherwise. 142 // succeed if the worker was previously subscribed with a numeric key
143 // and fail otherwise.
143 navigator.serviceWorker.controller.postMessage( 144 navigator.serviceWorker.controller.postMessage(
144 {command: 'workerSubscribeNoKey'}); 145 {command: 'workerSubscribeNoKey'});
145 } 146 }
146 147
147 function GetP256dh() { 148 function GetP256dh() {
148 navigator.serviceWorker.ready.then(function(swRegistration) { 149 navigator.serviceWorker.ready.then(function(swRegistration) {
149 return swRegistration.pushManager.getSubscription() 150 return swRegistration.pushManager.getSubscription()
150 .then(function(subscription) { 151 .then(function(subscription) {
151 sendResultToTest(btoa(String.fromCharCode.apply(null, 152 sendResultToTest(btoa(String.fromCharCode.apply(null,
152 new Uint8Array(subscription.getKey('p256dh'))))); 153 new Uint8Array(subscription.getKey('p256dh')))));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 }).catch(sendErrorToTest); 219 }).catch(sendErrorToTest);
219 } 220 }
220 221
221 navigator.serviceWorker.addEventListener('message', function(event) { 222 navigator.serviceWorker.addEventListener('message', function(event) {
222 var message = JSON.parse(event.data); 223 var message = JSON.parse(event.data);
223 if (message.type == 'push') 224 if (message.type == 'push')
224 resultQueue.push(message.data); 225 resultQueue.push(message.data);
225 else 226 else
226 sendResultToTest(message.data); 227 sendResultToTest(message.data);
227 }, false); 228 }, false);
OLDNEW
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_browsertest.cc ('k') | chrome/test/data/push_messaging/test_no_manifest.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698