Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 "use strict";
7 this.EXPORTED_SYMBOLS = [
8 "TestingUtils",
9 ];
11 this.TestingUtils = {
12 /**
13 * Perform a deep copy of an Array or Object.
14 */
15 deepCopy: function deepCopy(thing, noSort) {
16 if (typeof(thing) != "object" || thing == null) {
17 return thing;
18 }
20 if (Array.isArray(thing)) {
21 let ret = [];
22 for (let element of thing) {
23 ret.push(this.deepCopy(element, noSort));
24 }
26 return ret;
27 }
29 let ret = {};
30 let props = [p for (p in thing)];
32 if (!noSort) {
33 props = props.sort();
34 }
36 for (let prop of props) {
37 ret[prop] = this.deepCopy(thing[prop], noSort);
38 }
40 return ret;
41 },
42 };