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

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: rebase 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
134 function GetP256dh() { 147 function GetP256dh() {
135 navigator.serviceWorker.ready.then(function(swRegistration) { 148 navigator.serviceWorker.ready.then(function(swRegistration) {
136 return swRegistration.pushManager.getSubscription() 149 return swRegistration.pushManager.getSubscription()
137 .then(function(subscription) { 150 .then(function(subscription) {
138 sendResultToTest(btoa(String.fromCharCode.apply(null, 151 sendResultToTest(btoa(String.fromCharCode.apply(null,
139 new Uint8Array(subscription.getKey('p256dh'))))); 152 new Uint8Array(subscription.getKey('p256dh')))));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 }).catch(sendErrorToTest); 218 }).catch(sendErrorToTest);
206 } 219 }
207 220
208 navigator.serviceWorker.addEventListener('message', function(event) { 221 navigator.serviceWorker.addEventListener('message', function(event) {
209 var message = JSON.parse(event.data); 222 var message = JSON.parse(event.data);
210 if (message.type == 'push') 223 if (message.type == 'push')
211 resultQueue.push(message.data); 224 resultQueue.push(message.data);
212 else 225 else
213 sendResultToTest(message.data); 226 sendResultToTest(message.data);
214 }, false); 227 }, false);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698