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

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

Issue 2469293002: Handle push resubscribes with no sender info (avoids DCHECK) (Closed)
Patch Set: call it fixed_sender_id when it is (hopefully) fixed 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 return swRegistration.pushManager.subscribe({ 112 return swRegistration.pushManager.subscribe({
113 userVisibleOnly: true, 113 userVisibleOnly: true,
114 applicationServerKey: kApplicationServerKey.buffer 114 applicationServerKey: kApplicationServerKey.buffer
115 }) 115 })
116 .then(function(subscription) { 116 .then(function(subscription) {
117 sendResultToTest(subscription.endpoint); 117 sendResultToTest(subscription.endpoint);
118 }); 118 });
119 }).catch(sendErrorToTest); 119 }).catch(sendErrorToTest);
120 } 120 }
121 121
122 function documentSubscribePushWithNumericKey() {
123 navigator.serviceWorker.ready.then(function(swRegistration) {
124 return swRegistration.pushManager.subscribe({
125 userVisibleOnly: true,
126 applicationServerKey: new TextEncoder().encode('1234567890')
127 })
128 .then(function(subscription) {
129 sendResultToTest(subscription.endpoint);
130 });
131 }).catch(sendErrorToTest);
132 }
133
122 function workerSubscribePush() { 134 function workerSubscribePush() {
123 // Send the message to the worker for it to subscribe 135 // Send the message to the worker for it to subscribe
124 navigator.serviceWorker.controller.postMessage({command: 'workerSubscribe'}); 136 navigator.serviceWorker.controller.postMessage({command: 'workerSubscribe'});
125 } 137 }
126 138
127 function workerSubscribePushNoKey() { 139 function workerSubscribePushNoKey() {
128 // 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
129 // succeed if the worker was previously subscribed and fail otherwise. 141 // succeed if the worker was previously subscribed with a numeric key
142 // and fail otherwise.
130 navigator.serviceWorker.controller.postMessage( 143 navigator.serviceWorker.controller.postMessage(
131 {command: 'workerSubscribeNoKey'}); 144 {command: 'workerSubscribeNoKey'});
132 } 145 }
133 146
147 function workerSubscribePushWithNumericKey() {
148 // Send the message to the worker for it to subscribe
149 navigator.serviceWorker.controller.postMessage(
150 {command: 'workerSubscribeWithNumericKey'});
151 }
152
134 function GetP256dh() { 153 function GetP256dh() {
135 navigator.serviceWorker.ready.then(function(swRegistration) { 154 navigator.serviceWorker.ready.then(function(swRegistration) {
136 return swRegistration.pushManager.getSubscription() 155 return swRegistration.pushManager.getSubscription()
137 .then(function(subscription) { 156 .then(function(subscription) {
138 sendResultToTest(btoa(String.fromCharCode.apply(null, 157 sendResultToTest(btoa(String.fromCharCode.apply(null,
139 new Uint8Array(subscription.getKey('p256dh'))))); 158 new Uint8Array(subscription.getKey('p256dh')))));
140 }); 159 });
141 }).catch(sendErrorToTest); 160 }).catch(sendErrorToTest);
142 } 161 }
143 162
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 }).catch(sendErrorToTest); 224 }).catch(sendErrorToTest);
206 } 225 }
207 226
208 navigator.serviceWorker.addEventListener('message', function(event) { 227 navigator.serviceWorker.addEventListener('message', function(event) {
209 var message = JSON.parse(event.data); 228 var message = JSON.parse(event.data);
210 if (message.type == 'push') 229 if (message.type == 'push')
211 resultQueue.push(message.data); 230 resultQueue.push(message.data);
212 else 231 else
213 sendResultToTest(message.data); 232 sendResultToTest(message.data);
214 }, 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