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

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

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