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

Side by Side Diff: chrome/test/data/extensions/api_test/instance_id/delete_token/delete_token.js

Issue 1137463003: Support getting and deleting token for Instance ID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add new files Created 5 years, 7 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 function dummyGetTokenCompleted(token) { 5 function dummyGetTokenCompleted(token) {
6 } 6 }
7 7
8 function deleteTokenWithoutParameters() { 8 function deleteTokenWithoutParameters() {
9 try { 9 try {
10 chrome.instanceID.deleteToken(); 10 chrome.instanceID.deleteToken();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 return; 103 return;
104 } 104 }
105 105
106 chrome.test.succeed(); 106 chrome.test.succeed();
107 } 107 }
108 ); 108 );
109 } 109 }
110 ); 110 );
111 } 111 }
112 112
113 var oldToken;
fgorski 2015/05/13 18:32:38 put this inside of the test.
jianli 2015/05/13 22:42:55 I can't do this because oldToken are referred from
114 function getTokenDeleteTokeAndGetToken() {
115 chrome.instanceID.getToken(
116 {"authorizedEntity": "1", "scope": "GCM"},
117 function(token) {
118 if (chrome.runtime.lastError || !token) {
119 chrome.test.fail(
120 "chrome.runtime.lastError was set or token was empty.");
121 return;
122 }
123 oldToken = token;
124 chrome.instanceID.deleteToken(
125 {"authorizedEntity": "1", "scope": "GCM"},
126 function() {
127 if (chrome.runtime.lastError) {
128 chrome.test.fail("chrome.runtime.lastError: " +
129 chrome.runtime.lastError.message);
130 return;
131 }
132
133 chrome.instanceID.getToken(
134 {"authorizedEntity": "1", "scope": "GCM"},
135 function(token) {
136 if (!token || token == oldToken) {
137 chrome.test.fail(
138 "Different token should be returned after deleteToken.");
139 return;
140 }
141 chrome.test.succeed();
142 }
143 );
144 }
145 );
146 }
147 );
148 }
149
113 chrome.test.runTests([ 150 chrome.test.runTests([
114 deleteTokenWithoutParameters, 151 deleteTokenWithoutParameters,
115 deleteTokenWithoutCallback, 152 deleteTokenWithoutCallback,
116 deleteTokenWithoutAuthorizedEntity, 153 deleteTokenWithoutAuthorizedEntity,
117 deleteTokenWithInvalidAuthorizedEntity, 154 deleteTokenWithInvalidAuthorizedEntity,
118 deleteTokenWithoutScope, 155 deleteTokenWithoutScope,
119 deleteTokenWithInvalidScope, 156 deleteTokenWithInvalidScope,
120 // TODO(jianli): To be enabled when deleteToken is implemented. 157 deleteTokenBeforeGetToken,
121 //deleteTokenBeforeGetToken, 158 deleteTokenAfterGetToken,
122 //deleteTokenAfterGetToken, 159 getTokenDeleteTokeAndGetToken,
123 //getTokenDeleteTokeAndGetToken,
124 ]); 160 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698