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

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

Issue 2487233002: Handle push resubscribes with no sender info (avoids DCHECK) (Closed)
Patch Set: Handle push resubscribes with no sender info (avoids DCHECK) 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 invalidApplicationServerKey.fill('0x05', 1, 300); 118 invalidApplicationServerKey.fill('0x05', 1, 300);
119 pushSubscriptionOptions.applicationServerKey = 119 pushSubscriptionOptions.applicationServerKey =
120 invalidApplicationServerKey.buffer; 120 invalidApplicationServerKey.buffer;
121 return swRegistration.pushManager.subscribe(pushSubscriptionOptions) 121 return swRegistration.pushManager.subscribe(pushSubscriptionOptions)
122 .then(function(subscription) { 122 .then(function(subscription) {
123 sendResultToTest(subscription.endpoint); 123 sendResultToTest(subscription.endpoint);
124 }); 124 });
125 }).catch(sendErrorToTest); 125 }).catch(sendErrorToTest);
126 } 126 }
127 127
128 function documentSubscribePushWithNumericKey() {
129 navigator.serviceWorker.ready.then(function(swRegistration) {
130 return swRegistration.pushManager.subscribe({
131 userVisibleOnly: true,
132 applicationServerKey: new TextEncoder().encode('1234567890')
133 })
134 .then(function(subscription) {
135 sendResultToTest(subscription.endpoint);
136 });
137 }).catch(sendErrorToTest);
138 }
139
128 function workerSubscribePush() { 140 function workerSubscribePush() {
129 // Send the message to the worker for it to subscribe 141 // Send the message to the worker for it to subscribe
130 navigator.serviceWorker.controller.postMessage({command: 'workerSubscribe'}); 142 navigator.serviceWorker.controller.postMessage({command: 'workerSubscribe'});
131 } 143 }
132 144
133 function workerSubscribePushNoKey() { 145 function workerSubscribePushNoKey() {
134 // The worker will try to subscribe without providing a key. This should 146 // The worker will try to subscribe without providing a key. This should
135 // succeed if the worker was previously subscribed and fail otherwise. 147 // succeed if the worker was previously subscribed with a numeric key
148 // and fail otherwise.
136 navigator.serviceWorker.controller.postMessage( 149 navigator.serviceWorker.controller.postMessage(
137 {command: 'workerSubscribeNoKey'}); 150 {command: 'workerSubscribeNoKey'});
138 } 151 }
139 152
153 function workerSubscribePushWithNumericKey() {
154 // Send the message to the worker for it to subscribe
155 navigator.serviceWorker.controller.postMessage(
156 {command: 'workerSubscribeWithNumericKey'});
157 }
158
140 function GetP256dh() { 159 function GetP256dh() {
141 navigator.serviceWorker.ready.then(function(swRegistration) { 160 navigator.serviceWorker.ready.then(function(swRegistration) {
142 return swRegistration.pushManager.getSubscription() 161 return swRegistration.pushManager.getSubscription()
143 .then(function(subscription) { 162 .then(function(subscription) {
144 sendResultToTest(btoa(String.fromCharCode.apply(null, 163 sendResultToTest(btoa(String.fromCharCode.apply(null,
145 new Uint8Array(subscription.getKey('p256dh'))))); 164 new Uint8Array(subscription.getKey('p256dh')))));
146 }); 165 });
147 }).catch(sendErrorToTest); 166 }).catch(sendErrorToTest);
148 } 167 }
149 168
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 }).catch(sendErrorToTest); 230 }).catch(sendErrorToTest);
212 } 231 }
213 232
214 navigator.serviceWorker.addEventListener('message', function(event) { 233 navigator.serviceWorker.addEventListener('message', function(event) {
215 var message = JSON.parse(event.data); 234 var message = JSON.parse(event.data);
216 if (message.type == 'push') 235 if (message.type == 'push')
217 resultQueue.push(message.data); 236 resultQueue.push(message.data);
218 else 237 else
219 sendResultToTest(message.data); 238 sendResultToTest(message.data);
220 }, false); 239 }, 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