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

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

Issue 1314893002: Update a test to use PushSubscription.getKey() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 var resultQueue = new ResultQueue(); 7 var resultQueue = new ResultQueue();
8 var pushSubscription = null; 8 var pushSubscription = null;
9 9
10 var pushSubscriptionOptions = { 10 var pushSubscriptionOptions = {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 sendResultToTest(subscription.endpoint); 104 sendResultToTest(subscription.endpoint);
105 }); 105 });
106 }).catch(sendErrorToTest); 106 }).catch(sendErrorToTest);
107 } 107 }
108 108
109 function getCurve25519dh() { 109 function getCurve25519dh() {
110 navigator.serviceWorker.ready.then(function(swRegistration) { 110 navigator.serviceWorker.ready.then(function(swRegistration) {
111 return swRegistration.pushManager.getSubscription() 111 return swRegistration.pushManager.getSubscription()
112 .then(function(subscription) { 112 .then(function(subscription) {
113 sendResultToTest(btoa(String.fromCharCode.apply(null, 113 sendResultToTest(btoa(String.fromCharCode.apply(null,
114 new Uint8Array(subscription.curve25519dh)))); 114 new Uint8Array(subscription.getKey('curve25519dh')))));
115 }); 115 });
116 }).catch(sendErrorToTest); 116 }).catch(sendErrorToTest);
117 } 117 }
118 118
119 function permissionState() { 119 function permissionState() {
120 navigator.serviceWorker.ready.then(function(swRegistration) { 120 navigator.serviceWorker.ready.then(function(swRegistration) {
121 return swRegistration.pushManager.permissionState(pushSubscriptionOptions) 121 return swRegistration.pushManager.permissionState(pushSubscriptionOptions)
122 .then(function(permission) { 122 .then(function(permission) {
123 sendResultToTest('permission status - ' + permission); 123 sendResultToTest('permission status - ' + permission);
124 }); 124 });
(...skipping 28 matching lines...) Expand all
153 sendResultToTest(subscription ? 'true - subscribed' 153 sendResultToTest(subscription ? 'true - subscribed'
154 : 'false - not subscribed'); 154 : 'false - not subscribed');
155 }).catch(sendErrorToTest); 155 }).catch(sendErrorToTest);
156 } 156 }
157 157
158 navigator.serviceWorker.addEventListener('message', function(event) { 158 navigator.serviceWorker.addEventListener('message', function(event) {
159 var message = JSON.parse(event.data); 159 var message = JSON.parse(event.data);
160 if (message.type == 'push') 160 if (message.type == 'push')
161 resultQueue.push(message.data); 161 resultQueue.push(message.data);
162 }, false); 162 }, false);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698