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

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

Issue 2436393002: Disallow repeated PushManager.subscribes with different sender ids (Closed)
Patch Set: Make error message more informative Created 4 years, 1 month 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 137 }
138 138
139 function workerSubscribePushNoKey() { 139 function workerSubscribePushNoKey() {
140 // The worker will try to subscribe without providing a key. This should 140 // The worker will try to subscribe without providing a key. This should
141 // succeed if the worker was previously subscribed with a numeric key 141 // succeed if the worker was previously subscribed with a numeric key
142 // and fail otherwise. 142 // and fail otherwise.
143 navigator.serviceWorker.controller.postMessage( 143 navigator.serviceWorker.controller.postMessage(
144 {command: 'workerSubscribeNoKey'}); 144 {command: 'workerSubscribeNoKey'});
145 } 145 }
146 146
147 function workerSubscribePushWithNumericKey() { 147 function workerSubscribePushWithNumericKey(numericKey = '1234567890') {
148 // Send the message to the worker for it to subscribe 148 // Send the message to the worker for it to subscribe with the given key
149 navigator.serviceWorker.controller.postMessage( 149 navigator.serviceWorker.controller.postMessage(
150 {command: 'workerSubscribeWithNumericKey'}); 150 {command: 'workerSubscribeWithNumericKey', key: numericKey});
151 } 151 }
152 152
153 function GetP256dh() { 153 function GetP256dh() {
154 navigator.serviceWorker.ready.then(function(swRegistration) { 154 navigator.serviceWorker.ready.then(function(swRegistration) {
155 return swRegistration.pushManager.getSubscription() 155 return swRegistration.pushManager.getSubscription()
156 .then(function(subscription) { 156 .then(function(subscription) {
157 sendResultToTest(btoa(String.fromCharCode.apply(null, 157 sendResultToTest(btoa(String.fromCharCode.apply(null,
158 new Uint8Array(subscription.getKey('p256dh'))))); 158 new Uint8Array(subscription.getKey('p256dh')))));
159 }); 159 });
160 }).catch(sendErrorToTest); 160 }).catch(sendErrorToTest);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 }).catch(sendErrorToTest); 224 }).catch(sendErrorToTest);
225 } 225 }
226 226
227 navigator.serviceWorker.addEventListener('message', function(event) { 227 navigator.serviceWorker.addEventListener('message', function(event) {
228 var message = JSON.parse(event.data); 228 var message = JSON.parse(event.data);
229 if (message.type == 'push') 229 if (message.type == 'push')
230 resultQueue.push(message.data); 230 resultQueue.push(message.data);
231 else 231 else
232 sendResultToTest(message.data); 232 sendResultToTest(message.data);
233 }, false); 233 }, false);
OLDNEW
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_browsertest.cc ('k') | chrome/test/data/push_messaging/service_worker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698