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

Side by Side Diff: remoting/webapp/base/js/base.js

Issue 1055313002: Added mock_xhr module w/ unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * A module that contains basic utility components and methods for the 7 * A module that contains basic utility components and methods for the
8 * chromoting project 8 * chromoting project
9 * 9 *
10 */ 10 */
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 * (e.g. undefined, NaN). 208 * (e.g. undefined, NaN).
209 */ 209 */
210 base.deepCopy = function(value) { 210 base.deepCopy = function(value) {
211 try { 211 try {
212 return JSON.parse(JSON.stringify(value)); 212 return JSON.parse(JSON.stringify(value));
213 } catch (e) {} 213 } catch (e) {}
214 return null; 214 return null;
215 }; 215 };
216 216
217 /** 217 /**
218 * Returns a copy of the input object with all null/undefined fields
John Williams 2015/04/02 23:57:05 Moved from xhr.js.
219 * removed. Returns an empty object for a null/undefined input.
220 *
221 * @param {Object<string,?T>|undefined} input
222 * @return {!Object<string,T>}
223 * @template T
224 */
225 base.copyWithoutNullFields = function(input) {
226 /** @const {!Object} */
227 var result = {};
228 if (input) {
229 for (var field in input) {
230 var value = /** @type {*} */ (input[field]);
231 if (value != null) {
Jamie 2015/04/03 01:45:56 Is "value != null" the same as "value !== null &&
John Williams 2015/04/04 01:40:25 Correct.
232 result[field] = value;
233 }
234 }
235 }
236 return result;
237 };
238
239 /**
218 * @type {boolean|undefined} 240 * @type {boolean|undefined}
219 * @private 241 * @private
220 */ 242 */
221 base.isAppsV2_ = undefined; 243 base.isAppsV2_ = undefined;
222 244
223 /** 245 /**
224 * @return {boolean} True if this is a v2 app; false if it is a legacy app. 246 * @return {boolean} True if this is a v2 app; false if it is a legacy app.
225 */ 247 */
226 base.isAppsV2 = function() { 248 base.isAppsV2 = function() {
227 if (base.isAppsV2_ === undefined) { 249 if (base.isAppsV2_ === undefined) {
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 */ 727 */
706 base.resizeWindowToContent = function() { 728 base.resizeWindowToContent = function() {
707 var appWindow = chrome.app.window.current(); 729 var appWindow = chrome.app.window.current();
708 var outerBounds = appWindow.outerBounds; 730 var outerBounds = appWindow.outerBounds;
709 var borderY = outerBounds.height - appWindow.innerBounds.height; 731 var borderY = outerBounds.height - appWindow.innerBounds.height;
710 appWindow.resizeTo(outerBounds.width, document.body.clientHeight + borderY); 732 appWindow.resizeTo(outerBounds.width, document.body.clientHeight + borderY);
711 // Sometimes, resizing the window causes its position to be reset to (0, 0), 733 // Sometimes, resizing the window causes its position to be reset to (0, 0),
712 // so restore it explicitly. 734 // so restore it explicitly.
713 appWindow.moveTo(outerBounds.left, outerBounds.top); 735 appWindow.moveTo(outerBounds.left, outerBounds.top);
714 }; 736 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698