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

Side by Side Diff: remoting/webapp/js_proto/chrome_mocks.js

Issue 1015043002: Add optional scopes parameter to Identity.getToken(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 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 // This file contains various mock objects for the chrome platform to make 5 // This file contains various mock objects for the chrome platform to make
6 // unit testing easier. 6 // unit testing easier.
7 7
8 Entry = function() {}; 8 Entry = function() {};
9 9
10 var chromeMocks = {}; 10 var chromeMocks = {};
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 chromeMocks.Identity = function() { 185 chromeMocks.Identity = function() {
186 /** @private {string|undefined} */ 186 /** @private {string|undefined} */
187 this.token_ = undefined; 187 this.token_ = undefined;
188 }; 188 };
189 189
190 /** 190 /**
191 * @param {Object} options 191 * @param {Object} options
192 * @param {function(string=):void} callback 192 * @param {function(string=):void} callback
193 */ 193 */
194 chromeMocks.Identity.prototype.getAuthToken = function(options, callback) { 194 chromeMocks.Identity.prototype.getAuthToken = function(options, callback) {
195 // Append the 'scopes' array, if present, to the dummy token.
196 var token = this.token_;
197 if (token !== undefined && options['scopes'] !== undefined) {
198 token += JSON.stringify(options['scopes']);
199 }
195 // Don't use setTimeout because sinon mocks it. 200 // Don't use setTimeout because sinon mocks it.
196 window.requestAnimationFrame(callback.bind(null, this.token_)); 201 window.requestAnimationFrame(callback.bind(null, token));
197 }; 202 };
198 203
199 /** @param {string} token */ 204 /** @param {string} token */
200 chromeMocks.Identity.prototype.mock$setToken = function(token) { 205 chromeMocks.Identity.prototype.mock$setToken = function(token) {
201 this.token_ = token; 206 this.token_ = token;
202 }; 207 };
203 208
204 chromeMocks.Identity.prototype.mock$clearToken = function() { 209 chromeMocks.Identity.prototype.mock$clearToken = function() {
205 this.token_ = undefined; 210 this.token_ = undefined;
206 }; 211 };
(...skipping 26 matching lines...) Expand all
233 if (!originals_) { 238 if (!originals_) {
234 throw new Error('You must call activate() before restore().'); 239 throw new Error('You must call activate() before restore().');
235 } 240 }
236 for (var components in originals_) { 241 for (var components in originals_) {
237 chrome[components] = originals_[components]; 242 chrome[components] = originals_[components];
238 } 243 }
239 originals_ = null; 244 originals_ = null;
240 }; 245 };
241 246
242 })(); 247 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698