зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1400394 - Remove `TestingUtils.deepCopy`. r=markh
MozReview-Commit-ID: 3ZZpA3inWSF --HG-- extra : rebase_source : 506d1bb5bba484e65bcd5abed196c3ecc751fb1b
This commit is contained in:
Родитель
53fa8550dd
Коммит
95856672f4
|
@ -1,42 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
this.EXPORTED_SYMBOLS = [
|
|
||||||
"TestingUtils",
|
|
||||||
];
|
|
||||||
|
|
||||||
this.TestingUtils = {
|
|
||||||
/**
|
|
||||||
* Perform a deep copy of an Array or Object.
|
|
||||||
*/
|
|
||||||
deepCopy: function deepCopy(thing, noSort) {
|
|
||||||
if (typeof(thing) != "object" || thing == null) {
|
|
||||||
return thing;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(thing)) {
|
|
||||||
let ret = [];
|
|
||||||
for (let element of thing) {
|
|
||||||
ret.push(this.deepCopy(element, noSort));
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
let ret = {};
|
|
||||||
let props = Object.keys(thing);
|
|
||||||
|
|
||||||
if (!noSort) {
|
|
||||||
props = props.sort();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let prop of props) {
|
|
||||||
ret[prop] = this.deepCopy(thing[prop], noSort);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -40,7 +40,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android':
|
||||||
|
|
||||||
TESTING_JS_MODULES.services.common += [
|
TESTING_JS_MODULES.services.common += [
|
||||||
'modules-testing/logging.js',
|
'modules-testing/logging.js',
|
||||||
'modules-testing/utils.js',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
JS_PREFERENCE_FILES += [
|
JS_PREFERENCE_FILES += [
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
/* Any copyright is dedicated to the Public Domain.
|
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
||||||
|
|
||||||
Cu.import("resource://testing-common/services/common/utils.js");
|
|
||||||
|
|
||||||
function run_test() {
|
|
||||||
let thing = {o: {foo: "foo", bar: ["bar"]}, a: ["foo", {bar: "bar"}]};
|
|
||||||
let ret = TestingUtils.deepCopy(thing);
|
|
||||||
do_check_neq(ret, thing)
|
|
||||||
do_check_neq(ret.o, thing.o);
|
|
||||||
do_check_neq(ret.o.bar, thing.o.bar);
|
|
||||||
do_check_neq(ret.a, thing.a);
|
|
||||||
do_check_neq(ret.a[1], thing.a[1]);
|
|
||||||
do_check_eq(ret.o.foo, thing.o.foo);
|
|
||||||
do_check_eq(ret.o.bar[0], thing.o.bar[0]);
|
|
||||||
do_check_eq(ret.a[0], thing.a[0]);
|
|
||||||
do_check_eq(ret.a[1].bar, thing.a[1].bar);
|
|
||||||
}
|
|
|
@ -31,7 +31,6 @@ tags = blocklist
|
||||||
[test_utils_atob.js]
|
[test_utils_atob.js]
|
||||||
[test_utils_convert_string.js]
|
[test_utils_convert_string.js]
|
||||||
[test_utils_dateprefs.js]
|
[test_utils_dateprefs.js]
|
||||||
[test_utils_deepCopy.js]
|
|
||||||
[test_utils_encodeBase32.js]
|
[test_utils_encodeBase32.js]
|
||||||
[test_utils_encodeBase64URL.js]
|
[test_utils_encodeBase64URL.js]
|
||||||
[test_utils_ensureMillisecondsTimestamp.js]
|
[test_utils_ensureMillisecondsTimestamp.js]
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
Cu.import("resource://services-common/async.js");
|
Cu.import("resource://services-common/async.js");
|
||||||
Cu.import("resource://services-common/utils.js");
|
Cu.import("resource://services-common/utils.js");
|
||||||
Cu.import("resource://testing-common/services/common/utils.js");
|
|
||||||
Cu.import("resource://testing-common/PlacesTestUtils.jsm");
|
Cu.import("resource://testing-common/PlacesTestUtils.jsm");
|
||||||
Cu.import("resource://services-sync/util.js");
|
Cu.import("resource://services-sync/util.js");
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
@ -239,14 +238,14 @@ function mockGetWindowEnumerator(url, numWindows, numTabs, indexes, moreURLs) {
|
||||||
elements.push(win);
|
elements.push(win);
|
||||||
|
|
||||||
for (let t = 0; t < numTabs; ++t) {
|
for (let t = 0; t < numTabs; ++t) {
|
||||||
tabs.push(TestingUtils.deepCopy({
|
tabs.push(Cu.cloneInto({
|
||||||
index: indexes ? indexes() : 1,
|
index: indexes ? indexes() : 1,
|
||||||
entries: (moreURLs ? [url].concat(moreURLs()) : [url]).map(url2entry),
|
entries: (moreURLs ? [url].concat(moreURLs()) : [url]).map(url2entry),
|
||||||
attributes: {
|
attributes: {
|
||||||
image: "image"
|
image: "image"
|
||||||
},
|
},
|
||||||
lastAccessed: 1499
|
lastAccessed: 1499
|
||||||
}));
|
}, {}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ Cu.import("resource://services-sync/engines.js");
|
||||||
Cu.import("resource://services-sync/engines/bookmarks.js");
|
Cu.import("resource://services-sync/engines/bookmarks.js");
|
||||||
Cu.import("resource://services-sync/util.js");
|
Cu.import("resource://services-sync/util.js");
|
||||||
Cu.import("resource://services-sync/service.js");
|
Cu.import("resource://services-sync/service.js");
|
||||||
Cu.import("resource://testing-common/services/common/utils.js");
|
|
||||||
|
|
||||||
const DESCRIPTION_ANNO = "bookmarkProperties/description";
|
const DESCRIPTION_ANNO = "bookmarkProperties/description";
|
||||||
|
|
||||||
|
@ -55,7 +54,7 @@ const record631361 = {
|
||||||
function makeLivemark(p, mintGUID) {
|
function makeLivemark(p, mintGUID) {
|
||||||
let b = new Livemark("bookmarks", p.id);
|
let b = new Livemark("bookmarks", p.id);
|
||||||
// Copy here, because tests mutate the contents.
|
// Copy here, because tests mutate the contents.
|
||||||
b.cleartext = TestingUtils.deepCopy(p);
|
b.cleartext = Cu.cloneInto(p, {});
|
||||||
|
|
||||||
if (mintGUID)
|
if (mintGUID)
|
||||||
b.id = Utils.makeGUID();
|
b.id = Utils.makeGUID();
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
Cu.import("resource://services-sync/engines/tabs.js");
|
Cu.import("resource://services-sync/engines/tabs.js");
|
||||||
Cu.import("resource://services-sync/service.js");
|
Cu.import("resource://services-sync/service.js");
|
||||||
Cu.import("resource://services-sync/util.js");
|
Cu.import("resource://services-sync/util.js");
|
||||||
Cu.import("resource://testing-common/services/common/utils.js");
|
|
||||||
|
|
||||||
async function getMockStore() {
|
async function getMockStore() {
|
||||||
let engine = new TabEngine(Service);
|
let engine = new TabEngine(Service);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче