--- a/services/sync/modules-testing/utils.js
+++ b/services/sync/modules-testing/utils.js
@@ -13,16 +13,17 @@ this.EXPORTED_SYMBOLS = [
"SyncTestingInfrastructure",
"waitForZeroTimer",
"promiseZeroTimer",
"promiseNamedTimer",
"MockFxaStorageManager",
"AccountState", // from a module import
"sumHistogram",
"getLoginTelemetryScalar",
+ "syncTestLogging",
];
var {utils: Cu} = Components;
Cu.import("resource://services-sync/status.js");
Cu.import("resource://services-common/utils.js");
Cu.import("resource://services-crypto/utils.js");
Cu.import("resource://services-sync/util.js");
@@ -225,24 +226,31 @@ this.configureIdentity = async function(
await ns.Service.identity.whenReadyToAuthenticate.promise;
// and cheat to avoid requiring each test do an explicit login - give it
// a cluster URL.
if (config.fxaccount.token.endpoint) {
ns.Service.clusterURL = config.fxaccount.token.endpoint;
}
};
+function syncTestLogging(level = "Trace") {
+ let logStats = initTestLogging(level);
+ Services.prefs.setStringPref("services.sync.log.logger", level);
+ Services.prefs.setStringPref("services.sync.log.logger.engine", "");
+ return logStats;
+}
+
this.SyncTestingInfrastructure = async function(server, username) {
let ns = {};
Cu.import("resource://services-sync/service.js", ns);
let config = makeIdentityConfig({ username });
await configureIdentity(config, server);
return {
- logStats: initTestLogging(),
+ logStats: syncTestLogging(),
fakeFilesystem: new FakeFilesystemService({}),
fakeGUIDService: new FakeGUIDService(),
fakeCryptoService: new FakeCryptoService(),
};
};
/**
* Turn WBO cleartext into fake "encrypted" payload as it goes over the wire.
--- a/services/sync/tests/unit/head_errorhandler_common.js
+++ b/services/sync/tests/unit/head_errorhandler_common.js
@@ -100,16 +100,17 @@ const EHTestsCommon = {
let newSyncKeyBundle = new BulkKeyBundle("crypto");
await newSyncKeyBundle.generateRandom();
let keys = Service.collectionKeys.asWBO();
await keys.encrypt(newSyncKeyBundle);
return keys.upload(Service.resource(Service.cryptoKeysURL));
},
async setUp(server) {
+ syncTestLogging();
await configureIdentity({ username: "johndoe" }, server);
return EHTestsCommon.generateAndUploadKeys();
},
async generateAndUploadKeys() {
await generateNewKeys(Service.collectionKeys);
let serverKeys = Service.collectionKeys.asWBO("crypto", "keys");
await serverKeys.encrypt(Service.identity.syncKeyBundle);
--- a/services/sync/tests/unit/head_helpers.js
+++ b/services/sync/tests/unit/head_helpers.js
@@ -13,18 +13,22 @@
Cu.import("resource://services-common/async.js");
Cu.import("resource://services-common/utils.js");
Cu.import("resource://testing-common/PlacesTestUtils.jsm");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/PlacesUtils.jsm");
Cu.import("resource://gre/modules/PlacesSyncUtils.jsm");
Cu.import("resource://gre/modules/ObjectUtils.jsm");
+Cu.import("resource://testing-common/services/sync/utils.js");
add_task(async function head_setup() {
+ // Initialize logging. This will sometimes be reset by a pref reset,
+ // so it's also called as part of SyncTestingInfrastructure().
+ syncTestLogging();
// If a test imports Service, make sure it is initialized first.
if (this.Service) {
await this.Service.promiseInitialized;
}
});
// ================================================
// Load mocking/stubbing library, sinon
--- a/services/sync/tests/unit/test_412.js
+++ b/services/sync/tests/unit/test_412.js
@@ -1,18 +1,13 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/service.js");
Cu.import("resource://testing-common/services/sync/rotaryengine.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
-
-initTestLogging("Trace");
-
-Services.prefs.setCharPref("services.sync.log.logger.service.main", "Trace");
add_task(async function test_412_not_treated_as_failure() {
await Service.engineManager.register(RotaryEngine);
let engine = Service.engineManager.get("rotary");
let server = await serverForFoo(engine);
await SyncTestingInfrastructure(server);
--- a/services/sync/tests/unit/test_addon_utils.js
+++ b/services/sync/tests/unit/test_addon_utils.js
@@ -36,17 +36,17 @@ function createAndStartHTTPServer(port =
_("Got exception starting HTTP server on port " + port);
_("Error: " + Log.exceptionStr(ex));
do_throw(ex);
}
return null; /* not hit, but keeps eslint happy! */
}
function run_test() {
- initTestLogging("Trace");
+ syncTestLogging();
run_next_test();
}
add_test(function test_handle_empty_source_uri() {
_("Ensure that search results without a sourceURI are properly ignored.");
let server = createAndStartHTTPServer();
--- a/services/sync/tests/unit/test_addons_engine.js
+++ b/services/sync/tests/unit/test_addons_engine.js
@@ -6,17 +6,16 @@
Cu.import("resource://gre/modules/AddonManager.jsm");
Cu.import("resource://gre/modules/Preferences.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://services-common/async.js");
Cu.import("resource://services-sync/addonsreconciler.js");
Cu.import("resource://services-sync/engines/addons.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
const prefs = new Preferences();
prefs.set("extensions.getAddons.get.url",
"http://localhost:8888/search/guid:%IDS%");
prefs.set("extensions.install.requireSecureOrigin", false);
let engine;
let reconciler;
@@ -27,25 +26,16 @@ async function resetReconciler() {
reconciler._changes = [];
await reconciler.saveState();
tracker.clearChangedIDs();
}
add_task(async function setup() {
- initTestLogging("Trace");
- Log.repository.getLogger("Sync.Engine.Addons").level =
- Log.Level.Trace;
- Log.repository.getLogger("Sync.Store.Addons").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.Tracker.Addons").level =
- Log.Level.Trace;
- Log.repository.getLogger("Sync.AddonsRepository").level =
- Log.Level.Trace;
-
loadAddonTestFunctions();
startupManager();
await Service.engineManager.register(AddonsEngine);
engine = Service.engineManager.get("addons");
reconciler = engine._reconciler;
tracker = engine._tracker;
--- a/services/sync/tests/unit/test_addons_reconciler.js
+++ b/services/sync/tests/unit/test_addons_reconciler.js
@@ -8,21 +8,16 @@ Cu.import("resource://services-sync/addo
Cu.import("resource://services-sync/engines/addons.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
loadAddonTestFunctions();
startupManager();
add_task(async function run_test() {
- initTestLogging("Trace");
- Log.repository.getLogger("Sync.AddonsReconciler").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.AddonsReconciler").level =
- Log.Level.Trace;
-
Svc.Prefs.set("engine.addons", true);
await Service.engineManager.register(AddonsEngine);
});
add_task(async function test_defaults() {
_("Ensure new objects have reasonable defaults.");
let reconciler = new AddonsReconciler();
--- a/services/sync/tests/unit/test_addons_store.js
+++ b/services/sync/tests/unit/test_addons_store.js
@@ -4,17 +4,16 @@
"use strict";
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://gre/modules/Preferences.jsm");
Cu.import("resource://services-sync/addonutils.js");
Cu.import("resource://services-sync/engines/addons.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
Cu.import("resource://gre/modules/FileUtils.jsm");
const HTTP_PORT = 8888;
const prefs = new Preferences();
prefs.set("extensions.getAddons.get.url", "http://localhost:8888/search/guid:%IDS%");
prefs.set("extensions.install.requireSecureOrigin", false);
@@ -99,21 +98,16 @@ function createAndStartHTTPServer(port)
function checkReconcilerUpToDate(addon) {
let stateBefore = Object.assign({}, store.reconciler.addons[addon.id]);
store.reconciler.rectifyStateFromAddon(addon);
let stateAfter = store.reconciler.addons[addon.id];
deepEqual(stateBefore, stateAfter);
}
add_task(async function setup() {
- initTestLogging("Trace");
- Log.repository.getLogger("Sync.Engine.Addons").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.Tracker.Addons").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.AddonsRepository").level = Log.Level.Trace;
-
await Service.engineManager.register(AddonsEngine);
engine = Service.engineManager.get("addons");
tracker = engine._tracker;
store = engine._store;
reconciler = engine._reconciler;
reconciler.startListening();
--- a/services/sync/tests/unit/test_addons_tracker.js
+++ b/services/sync/tests/unit/test_addons_tracker.js
@@ -28,20 +28,16 @@ async function cleanup() {
tracker.clearChangedIDs();
reconciler._addons = {};
reconciler._changes = [];
await reconciler.saveState();
}
add_task(async function setup() {
- initTestLogging("Trace");
- Log.repository.getLogger("Sync.Engine.Addons").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.AddonsReconciler").level = Log.Level.Trace;
-
await Service.engineManager.register(AddonsEngine);
engine = Service.engineManager.get("addons");
reconciler = engine._reconciler;
store = engine._store;
tracker = engine._tracker;
// Don't write out by default.
tracker.persistChangedIDs = false;
--- a/services/sync/tests/unit/test_bookmark_decline_undecline.js
+++ b/services/sync/tests/unit/test_bookmark_decline_undecline.js
@@ -3,34 +3,28 @@
Cu.import("resource://gre/modules/BookmarkJSONUtils.jsm");
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/engines/bookmarks.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
-
-add_task(async function setup() {
- initTestLogging("Trace");
- await Service.engineManager.register(BookmarksEngine);
-});
// A stored reference to the collection won't be valid after disabling.
function getBookmarkWBO(server, guid) {
let coll = server.user("foo").collection("bookmarks");
if (!coll) {
return null;
}
return coll.wbo(guid);
}
add_task(async function setup() {
- initTestLogging("Trace");
+ await Service.engineManager.register(BookmarksEngine);
await generateNewKeys(Service.collectionKeys);
});
add_task(async function test_decline_undecline() {
let engine = Service.engineManager.get("bookmarks");
let server = await serverForFoo(engine);
await SyncTestingInfrastructure(server);
--- a/services/sync/tests/unit/test_bookmark_duping.js
+++ b/services/sync/tests/unit/test_bookmark_duping.js
@@ -1,35 +1,28 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-common/async.js");
-Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/engines/bookmarks.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
Cu.import("resource://services-sync/bookmark_validator.js");
const bms = PlacesUtils.bookmarks;
add_task(async function setup() {
- initTestLogging("Trace");
await Service.engineManager.unregister("bookmarks");
});
async function sharedSetup() {
let engine = new BookmarksEngine(Service);
await engine.initialize();
let store = engine._store;
-
- store._log.level = Log.Level.Trace;
- engine._log.level = Log.Level.Trace;
-
let server = await serverForFoo(engine);
await SyncTestingInfrastructure(server);
let collection = server.user("foo").collection("bookmarks");
Svc.Obs.notify("weave:engine:start-tracking"); // We skip usual startup...
return { engine, store, server, collection };
--- a/services/sync/tests/unit/test_bookmark_engine.js
+++ b/services/sync/tests/unit/test_bookmark_engine.js
@@ -6,20 +6,16 @@ Cu.import("resource://gre/modules/Bookma
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://services-common/utils.js");
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/engines/bookmarks.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
-
-
-initTestLogging("Trace");
async function fetchAllRecordIds() {
let db = await PlacesUtils.promiseDBConnection();
let rows = await db.executeCached(`
WITH RECURSIVE
syncedItems(id, guid) AS (
SELECT b.id, b.guid FROM moz_bookmarks b
WHERE b.guid IN ('menu________', 'toolbar_____', 'unfiled_____',
@@ -33,25 +29,18 @@ async function fetchAllRecordIds() {
for (let row of rows) {
let recordId = PlacesSyncUtils.bookmarks.guidToRecordId(
row.getResultByName("guid"));
recordIds.add(recordId);
}
return recordIds;
}
add_task(async function setup() {
- initTestLogging("Trace");
await generateNewKeys(Service.collectionKeys);
-});
-
-add_task(async function setup() {
await Service.engineManager.unregister("bookmarks");
-
- initTestLogging("Trace");
- generateNewKeys(Service.collectionKeys);
});
add_task(async function test_delete_invalid_roots_from_server() {
_("Ensure that we delete the Places and Reading List roots from the server.");
let engine = new BookmarksEngine(Service);
await engine.initialize();
let store = engine._store;
--- a/services/sync/tests/unit/test_bookmark_invalid.js
+++ b/services/sync/tests/unit/test_bookmark_invalid.js
@@ -4,17 +4,16 @@ Cu.import("resource://services-sync/engi
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
let engine;
let store;
let tracker;
add_task(async function setup() {
- initTestLogging("Trace");
engine = new BookmarksEngine(Service);
store = engine._store;
tracker = engine._tracker;
});
add_task(async function test_ignore_invalid_uri() {
_("Ensure that we don't die with invalid bookmarks.");
--- a/services/sync/tests/unit/test_bookmark_livemarks.js
+++ b/services/sync/tests/unit/test_bookmark_livemarks.js
@@ -54,22 +54,16 @@ function makeLivemark(p, mintGUID) {
b.cleartext = Cu.cloneInto(p, {});
if (mintGUID)
b.id = Utils.makeGUID();
return b;
}
-add_task(async function setup() {
- initTestLogging("Trace");
- Log.repository.getLogger("Sync.Engine.Bookmarks").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.Store.Bookmarks").level = Log.Level.Trace;
-});
-
add_task(async function test_livemark_descriptions() {
let engine = new BookmarksEngine(Service);
await engine.initialize();
let store = engine._store;
let record = record631361.payload;
async function doRecord(r) {
--- a/services/sync/tests/unit/test_bookmark_order.js
+++ b/services/sync/tests/unit/test_bookmark_order.js
@@ -2,21 +2,16 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
_("Making sure after processing incoming bookmarks, they show up in the right order");
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://services-sync/engines/bookmarks.js");
Cu.import("resource://services-sync/main.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
-
-Svc.Prefs.set("log.logger.engine.bookmarks", "Trace");
-initTestLogging("Trace");
-Log.repository.getLogger("Sqlite").level = Log.Level.Info;
async function serverForFoo(engine) {
await generateNewKeys(Service.collectionKeys);
let clientsEngine = Service.clientsEngine;
return serverForUsers({"foo": "password"}, {
meta: {
global: {
--- a/services/sync/tests/unit/test_bookmark_places_query_rewriting.js
+++ b/services/sync/tests/unit/test_bookmark_places_query_rewriting.js
@@ -16,19 +16,16 @@ function makeTagRecord(id, uri) {
tagRecord.bmkUri = uri;
tagRecord.title = "tagtag";
tagRecord.folderName = "bar";
tagRecord.parentid = PlacesUtils.bookmarks.toolbarGuid;
return tagRecord;
}
add_task(async function run_test() {
- initTestLogging("Trace");
- Log.repository.getLogger("Sync.Engine.Bookmarks").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.Store.Bookmarks").level = Log.Level.Trace;
let uri = "place:folder=499&type=7&queryType=1";
let tagRecord = makeTagRecord("abcdefabcdef", uri);
_("Type: " + tagRecord.type);
_("Folder name: " + tagRecord.folderName);
await store.applyIncoming(tagRecord);
--- a/services/sync/tests/unit/test_bookmark_record.js
+++ b/services/sync/tests/unit/test_bookmark_record.js
@@ -2,45 +2,41 @@
* http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://services-sync/engines/bookmarks.js");
Cu.import("resource://services-sync/keys.js");
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
function prepareBookmarkItem(collection, id) {
let b = new Bookmark(collection, id);
b.cleartext.stuff = "my payload here";
return b;
}
add_task(async function test_bookmark_record() {
await configureIdentity();
await generateNewKeys(Service.collectionKeys);
let keyBundle = Service.identity.syncKeyBundle;
- let log = Log.repository.getLogger("Test");
- Log.repository.rootLogger.addAppender(new Log.DumpAppender());
-
- log.info("Creating a record");
+ _("Creating a record");
let placesItem = new PlacesItem("bookmarks", "foo", "bookmark");
let bookmarkItem = prepareBookmarkItem("bookmarks", "foo");
- log.info("Checking getTypeObject");
+ _("Checking getTypeObject");
Assert.equal(placesItem.getTypeObject(placesItem.type), Bookmark);
Assert.equal(bookmarkItem.getTypeObject(bookmarkItem.type), Bookmark);
await bookmarkItem.encrypt(keyBundle);
- log.info("Ciphertext is " + bookmarkItem.ciphertext);
+ _("Ciphertext is " + bookmarkItem.ciphertext);
Assert.ok(bookmarkItem.ciphertext != null);
- log.info("Decrypting the record");
+ _("Decrypting the record");
let payload = await bookmarkItem.decrypt(keyBundle);
Assert.equal(payload.stuff, "my payload here");
Assert.equal(bookmarkItem.getTypeObject(bookmarkItem.type), Bookmark);
Assert.notEqual(payload, bookmarkItem.payload); // wrap.data.payload is the encrypted one
});
--- a/services/sync/tests/unit/test_bookmark_repair.js
+++ b/services/sync/tests/unit/test_bookmark_repair.js
@@ -6,17 +6,16 @@
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://services-sync/bookmark_repair.js");
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/doctor.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/engines/clients.js");
Cu.import("resource://services-sync/engines/bookmarks.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
const LAST_BOOKMARK_SYNC_PREFS = [
"bookmarks.lastSync",
"bookmarks.lastSyncLocal",
];
const BOOKMARK_REPAIR_STATE_PREFS = [
"client.GUID",
@@ -36,21 +35,16 @@ add_task(async function setup() {
clientsEngine.ignoreLastModifiedOnProcessCommands = true;
bookmarksEngine = Service.engineManager.get("bookmarks");
await generateNewKeys(Service.collectionKeys);
Service.recordTelemetryEvent = (object, method, value, extra = undefined) => {
recordedEvents.push({ object, method, value, extra });
};
-
- initTestLogging("Trace");
- Log.repository.getLogger("Sync.Engine.Bookmarks").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.Engine.Clients").level = Log.Level.Trace;
- Log.repository.getLogger("Sqlite").level = Log.Level.Info; // less noisy
});
function checkRecordedEvents(expected, message) {
deepEqual(recordedEvents, expected, message);
// and clear the list so future checks are easier to write.
recordedEvents = [];
}
--- a/services/sync/tests/unit/test_bookmark_repair_requestor.js
+++ b/services/sync/tests/unit/test_bookmark_repair_requestor.js
@@ -1,14 +1,12 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/bookmark_repair.js");
-initTestLogging("Trace");
-
function makeClientRecord(id, fields = {}) {
return {
id,
version: fields.version || "54.0a1",
type: fields.type || "desktop",
stale: fields.stale || false,
serverLastModified: fields.serverLastModified || 0,
};
--- a/services/sync/tests/unit/test_bookmark_repair_responder.js
+++ b/services/sync/tests/unit/test_bookmark_repair_responder.js
@@ -1,21 +1,16 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource:///modules/PlacesUIUtils.jsm");
-Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://services-sync/engines/bookmarks.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/bookmark_repair.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
-
-initTestLogging("Trace");
-Log.repository.getLogger("Sync.Engine.Bookmarks").level = Log.Level.Trace;
// Disable validation so that we don't try to automatically repair the server
// when we sync.
Svc.Prefs.set("engine.bookmarks.validation.enabled", false);
// stub telemetry so we can easily check the right things are recorded.
var recordedEvents = [];
--- a/services/sync/tests/unit/test_bookmark_smart_bookmarks.js
+++ b/services/sync/tests/unit/test_bookmark_smart_bookmarks.js
@@ -2,17 +2,16 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://services-common/utils.js");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/engines/bookmarks.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
async function newSmartBookmark(parentGuid, url, position, title, queryID) {
let info = await PlacesUtils.bookmarks.insert({
parentGuid,
url,
position,
title,
});
@@ -31,19 +30,16 @@ function smartBookmarkCount() {
PlacesSyncUtils.bookmarks.SMART_BOOKMARKS_ANNO, out);
return out.value;
}
let engine;
let store;
add_task(async function setup() {
- initTestLogging("Trace");
- Log.repository.getLogger("Sync.Engine.Bookmarks").level = Log.Level.Trace;
-
await generateNewKeys(Service.collectionKeys);
});
add_task(async function setup() {
await Service.engineManager.register(BookmarksEngine);
engine = Service.engineManager.get("bookmarks");
store = engine._store;
});
--- a/services/sync/tests/unit/test_bookmark_store.js
+++ b/services/sync/tests/unit/test_bookmark_store.js
@@ -562,14 +562,8 @@ add_task(async function test_delete_buff
equal(tbItem.parentGuid, PlacesUtils.bookmarks.toolbarGuid);
} finally {
_("Clean up.");
await store.wipe();
await engine.finalize();
}
});
-
-
-function run_test() {
- initTestLogging("Trace");
- run_next_test();
-}
--- a/services/sync/tests/unit/test_browserid_identity.js
+++ b/services/sync/tests/unit/test_browserid_identity.js
@@ -2,17 +2,16 @@
* http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://gre/modules/FxAccounts.jsm");
Cu.import("resource://services-sync/browserid_identity.js");
Cu.import("resource://services-sync/resource.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://services-common/utils.js");
Cu.import("resource://services-crypto/utils.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
Cu.import("resource://testing-common/services/sync/fxa_utils.js");
Cu.import("resource://services-common/hawkclient.js");
Cu.import("resource://gre/modules/FxAccounts.jsm");
Cu.import("resource://gre/modules/FxAccountsClient.jsm");
Cu.import("resource://gre/modules/FxAccountsCommon.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/status.js");
Cu.import("resource://services-sync/constants.js");
@@ -57,23 +56,16 @@ function MockFxAccounts() {
validUntil: fxa.internal.now() + CERT_LIFETIME,
cert: "certificate",
};
return Promise.resolve(this.cert.cert);
};
return fxa;
}
-function run_test() {
- initTestLogging("Trace");
- Log.repository.getLogger("Sync.Identity").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.BrowserIDManager").level = Log.Level.Trace;
- run_next_test();
-}
-
add_test(function test_initial_state() {
_("Verify initial state");
Assert.ok(!globalBrowseridManager._token);
Assert.ok(!globalBrowseridManager.hasValidToken());
run_next_test();
}
);
--- a/services/sync/tests/unit/test_browserid_identity_telemetry.js
+++ b/services/sync/tests/unit/test_browserid_identity_telemetry.js
@@ -1,10 +1,9 @@
Cu.import("resource://gre/modules/Preferences.jsm");
-Cu.import("resource://testing-common/services/sync/utils.js");
let {telemetryHelper} = Cu.import("resource://services-sync/browserid_identity.js", {});
const prefs = new Preferences("services.sync.");
function cleanup() {
prefs.resetBranch();
}
--- a/services/sync/tests/unit/test_clients_engine.js
+++ b/services/sync/tests/unit/test_clients_engine.js
@@ -2,17 +2,16 @@
* http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/engines/clients.js");
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
const MORE_THAN_CLIENTS_TTL_REFRESH = 691200; // 8 days
const LESS_THAN_CLIENTS_TTL_REFRESH = 86400; // 1 day
let engine;
/**
* Unpack the record with this ID, and verify that it has the same version that
@@ -56,16 +55,19 @@ async function syncClientsEngine(server)
add_task(async function setup() {
engine = Service.clientsEngine;
});
async function cleanup() {
Svc.Prefs.resetBranch("");
engine._tracker.clearChangedIDs();
await engine._resetClient();
+ // un-cleanup the logs (the resetBranch will have reset their levels), since
+ // not all the tests use SyncTestingInfrastructure, and it's cheap.
+ syncTestLogging();
// We don't finalize storage at cleanup, since we use the same clients engine
// instance across all tests.
}
add_task(async function test_bad_hmac() {
_("Ensure that Clients engine deletes corrupt records.");
let deletedCollections = [];
let deletedItems = [];
@@ -1887,14 +1889,8 @@ add_task(async function test_create_reco
try {
let collection = server.getCollection("foo", "clients");
collection.remove(remoteId);
} finally {
await promiseStopServer(server);
}
}
});
-
-function run_test() {
- initTestLogging("Trace");
- Log.repository.getLogger("Sync.Engine.Clients").level = Log.Level.Trace;
- run_next_test();
-}
--- a/services/sync/tests/unit/test_clients_escape.js
+++ b/services/sync/tests/unit/test_clients_escape.js
@@ -1,16 +1,15 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/keys.js");
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
add_task(async function test_clients_escape() {
_("Set up test fixtures.");
await configureIdentity();
let keyBundle = Service.identity.syncKeyBundle;
let engine = Service.clientsEngine;
--- a/services/sync/tests/unit/test_collection_getBatched.js
+++ b/services/sync/tests/unit/test_collection_getBatched.js
@@ -1,20 +1,14 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/service.js");
-function run_test() {
- initTestLogging("Trace");
- Log.repository.getLogger("Sync.Collection").level = Log.Level.Trace;
- run_next_test();
-}
-
function recordRange(lim, offset, total) {
let res = [];
for (let i = offset; i < Math.min(lim + offset, total); ++i) {
res.push(JSON.stringify({ id: String(i), payload: "test:" + i }));
}
return res;
}
--- a/services/sync/tests/unit/test_collections_recovery.js
+++ b/services/sync/tests/unit/test_collections_recovery.js
@@ -1,17 +1,14 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Verify that we wipe the server if we have to regenerate keys.
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
-
-initTestLogging("Trace");
add_task(async function test_missing_crypto_collection() {
enableValidationPrefs();
let johnHelper = track_collections_helper();
let johnU = johnHelper.with_updated_collection;
let johnColls = johnHelper.collections;
--- a/services/sync/tests/unit/test_corrupt_keys.js
+++ b/services/sync/tests/unit/test_corrupt_keys.js
@@ -7,17 +7,16 @@ Cu.import("resource://services-sync/cons
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/main.js");
Cu.import("resource://services-sync/engines/tabs.js");
Cu.import("resource://services-sync/engines/history.js");
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/status.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
add_task(async function test_locally_changed_keys() {
enableValidationPrefs();
let hmacErrorCount = 0;
function counting(f) {
return async function() {
hmacErrorCount++;
--- a/services/sync/tests/unit/test_doctor.js
+++ b/services/sync/tests/unit/test_doctor.js
@@ -1,16 +1,14 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const { Doctor, REPAIR_ADVANCE_PERIOD } = Cu.import("resource://services-sync/doctor.js", {});
Cu.import("resource://gre/modules/Services.jsm");
-initTestLogging("Trace");
-
function mockDoctor(mocks) {
// Clone the object and put mocks in that.
return Object.assign({}, Doctor, mocks);
}
add_task(async function test_validation_interval() {
let now = 1000;
let doctor = mockDoctor({
--- a/services/sync/tests/unit/test_engine_abort.js
+++ b/services/sync/tests/unit/test_engine_abort.js
@@ -1,17 +1,16 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/rotaryengine.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
add_task(async function test_processIncoming_abort() {
_("An abort exception, raised in applyIncoming, will abort _processIncoming.");
let engine = new RotaryEngine(Service);
let collection = new ServerCollection();
let id = Utils.makeGUID();
let payload = encryptPayload({id, denomination: "Record No. " + id});
--- a/services/sync/tests/unit/test_engine_changes_during_sync.js
+++ b/services/sync/tests/unit/test_engine_changes_during_sync.js
@@ -1,17 +1,16 @@
Cu.import("resource://gre/modules/FormHistory.jsm");
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/engines/bookmarks.js");
Cu.import("resource://services-sync/engines/history.js");
Cu.import("resource://services-sync/engines/forms.js");
Cu.import("resource://services-sync/engines/passwords.js");
Cu.import("resource://services-sync/engines/prefs.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
const LoginInfo = Components.Constructor(
"@mozilla.org/login-manager/loginInfo;1", Ci.nsILoginInfo, "init");
/**
* We don't test the clients or tabs engines because neither has conflict
* resolution logic. The clients engine syncs twice per global sync, and
* custom conflict resolution logic for commands that doesn't use
--- a/services/sync/tests/unit/test_errorhandler_1.js
+++ b/services/sync/tests/unit/test_errorhandler_1.js
@@ -4,17 +4,16 @@
Cu.import("resource://services-sync/engines/clients.js");
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/keys.js");
Cu.import("resource://services-sync/policies.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/status.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/PromiseUtils.jsm");
var fakeServer = new SyncServer();
fakeServer.start();
registerCleanupFunction(function() {
return new Promise(resolve => {
@@ -38,34 +37,30 @@ function setLastSync(lastSyncValue) {
}
// This relies on Service/ErrorHandler being a singleton. Fixing this will take
// a lot of work.
let errorHandler = Service.errorHandler;
let engine;
add_task(async function setup() {
- initTestLogging("Trace");
-
- Log.repository.getLogger("Sync.Service").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.SyncScheduler").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.ErrorHandler").level = Log.Level.Trace;
-
Service.engineManager.clear();
await Service.engineManager.register(EHTestsCommon.CatapultEngine);
engine = Service.engineManager.get("catapult");
});
async function clean() {
let promiseLogReset = promiseOneObserver("weave:service:reset-file-log");
await Service.startOver();
await promiseLogReset;
Status.resetSync();
Status.resetBackoff();
errorHandler.didReportProlongedError = false;
+ // Move log levels back to trace (startOver will have reversed this), sicne
+ syncTestLogging();
}
add_task(async function test_401_logout() {
enableValidationPrefs();
let server = await EHTestsCommon.sync_httpd_setup();
await EHTestsCommon.setUp(server);
@@ -132,16 +127,17 @@ add_task(async function test_credentials
Assert.ok(!Service.isLoggedIn);
// Clean up.
await Service.startOver();
await promiseStopServer(server);
});
add_task(function test_no_lastSync_pref() {
+ syncTestLogging();
// Test reported error.
Status.resetSync();
errorHandler.dontIgnoreErrors = true;
Status.sync = CREDENTIALS_CHANGED;
Assert.ok(errorHandler.shouldReportError());
// Test unreported error.
Status.resetSync();
--- a/services/sync/tests/unit/test_errorhandler_2.js
+++ b/services/sync/tests/unit/test_errorhandler_2.js
@@ -4,17 +4,16 @@
Cu.import("resource://services-sync/engines/clients.js");
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/keys.js");
Cu.import("resource://services-sync/policies.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/status.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/PromiseUtils.jsm");
var fakeServer = new SyncServer();
fakeServer.start();
registerCleanupFunction(function() {
return new Promise(resolve => {
@@ -71,36 +70,31 @@ async function syncAndReportErrorsAndWai
let promise1 = promiseOneObserver(topic);
// also wait for the log file to be written
let promise2 = promiseOneObserver("weave:service:reset-file-log");
errorHandler.syncAndReportErrors();
await promise1;
await promise2;
}
add_task(async function setup() {
- initTestLogging("Trace");
-
- Log.repository.getLogger("Sync.Service").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.SyncScheduler").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.ErrorHandler").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.LogManager").level = Log.Level.Trace;
-
Service.engineManager.clear();
await Service.engineManager.register(EHTestsCommon.CatapultEngine);
engine = Service.engineManager.get("catapult");
});
async function clean() {
let promiseLogReset = promiseOneObserver("weave:service:reset-file-log");
await Service.startOver();
await promiseLogReset;
Status.resetSync();
Status.resetBackoff();
errorHandler.didReportProlongedError = false;
removeLogFiles();
+ // Move log levels back to trace (startOver will have reversed this), sicne
+ syncTestLogging();
}
add_task(async function test_crypto_keys_login_server_maintenance_error() {
enableValidationPrefs();
Status.resetSync();
// Test crypto/keys server maintenance errors are not reported.
let server = await EHTestsCommon.sync_httpd_setup();
--- a/services/sync/tests/unit/test_errorhandler_eol.js
+++ b/services/sync/tests/unit/test_errorhandler_eol.js
@@ -1,17 +1,16 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/status.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/fakeservices.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
function baseHandler(eolCode, request, response, statusCode, status, body) {
let alertBody = {
code: eolCode,
message: "Service is EOLed.",
url: "http://getfirefox.com",
};
response.setHeader("X-Weave-Timestamp", "" + new_timestamp(), false);
--- a/services/sync/tests/unit/test_errorhandler_filelog.js
+++ b/services/sync/tests/unit/test_errorhandler_filelog.js
@@ -23,25 +23,17 @@ const PROLONGED_ERROR_DURATION =
var errorHandler = Service.errorHandler;
function setLastSync(lastSyncValue) {
Svc.Prefs.set("lastSync", (new Date(Date.now() - lastSyncValue)).toString());
}
function run_test() {
- initTestLogging("Trace");
-
- Log.repository.getLogger("Sync.LogManager").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.Service").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.SyncScheduler").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.ErrorHandler").level = Log.Level.Trace;
-
validate_all_future_pings();
-
run_next_test();
}
add_test(function test_noOutput() {
// Ensure that the log appender won't print anything.
errorHandler._logManager._fileAppender.level = Log.Level.Fatal + 1;
// Clear log output from startup.
--- a/services/sync/tests/unit/test_errorhandler_sync_checkServerError.js
+++ b/services/sync/tests/unit/test_errorhandler_sync_checkServerError.js
@@ -4,19 +4,16 @@
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/policies.js");
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/status.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/fakeservices.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
-
-initTestLogging("Trace");
var engineManager = Service.engineManager;
engineManager.clear();
function CatapultEngine() {
SyncEngine.call(this, "Catapult", Service);
}
CatapultEngine.prototype = {
@@ -50,16 +47,17 @@ async function sync_httpd_setup() {
"/1.1/johndoe/storage/crypto/keys": upd("crypto", keysWBO.handler())
};
return httpd_setup(handlers);
}
async function setUp(server) {
await configureIdentity({username: "johndoe"}, server);
new FakeCryptoService();
+ syncTestLogging();
}
async function generateAndUploadKeys(server) {
await generateNewKeys(Service.collectionKeys);
let serverKeys = Service.collectionKeys.asWBO("crypto", "keys");
await serverKeys.encrypt(Service.identity.syncKeyBundle);
let res = Service.resource(server.baseURI + "/1.1/johndoe/storage/crypto/keys");
return (await serverKeys.upload(res)).success;
--- a/services/sync/tests/unit/test_extension_storage_engine.js
+++ b/services/sync/tests/unit/test_extension_storage_engine.js
@@ -2,17 +2,16 @@
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/engines/extension-storage.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
Cu.import("resource://gre/modules/ExtensionStorageSync.jsm");
/* globals extensionStorageSync */
let engine;
function mock(options) {
let calls = [];
let ret = function() {
--- a/services/sync/tests/unit/test_fxa_node_reassignment.js
+++ b/services/sync/tests/unit/test_fxa_node_reassignment.js
@@ -11,27 +11,19 @@ Cu.import("resource://gre/modules/Log.js
Cu.import("resource://services-common/rest.js");
Cu.import("resource://services-common/utils.js");
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/status.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/rotaryengine.js");
Cu.import("resource://services-sync/browserid_identity.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
Cu.import("resource://gre/modules/PromiseUtils.jsm");
add_task(async function setup() {
- Log.repository.getLogger("Sync.ErrorHandler").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.Resource").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.RESTRequest").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.Service").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.SyncScheduler").level = Log.Level.Trace;
- initTestLogging();
-
// Disables all built-in engines. Important for avoiding errors thrown by the
// add-ons engine.
Service.engineManager.clear();
// Setup the FxA identity manager and cluster manager.
Status.__authManager = Service.identity = new BrowserIDManager();
Service._clusterManager = Service.identity.createClusterManager(Service);
@@ -51,16 +43,17 @@ function handleReassign(handler, req, re
resp.setHeader("Content-Type", "application/json");
let reassignBody = JSON.stringify({error: "401inator in place"});
resp.bodyOutputStream.write(reassignBody, reassignBody.length);
}
var numTokenRequests = 0;
function prepareServer(cbAfterTokenFetch) {
+ syncTestLogging();
let config = makeIdentityConfig({username: "johndoe"});
// A server callback to ensure we don't accidentally hit the wrong endpoint
// after a node reassignment.
let callback = {
__proto__: SyncServerCallback,
onRequest(req, resp) {
let full = `${req.scheme}://${req.host}:${req.port}${req.path}`;
Assert.ok(full.startsWith(config.fxaccount.token.endpoint),
--- a/services/sync/tests/unit/test_fxa_service_cluster.js
+++ b/services/sync/tests/unit/test_fxa_service_cluster.js
@@ -1,15 +1,14 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/fxa_utils.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
add_task(async function test_findCluster() {
_("Test FxA _findCluster()");
_("_findCluster() throws on 500 errors.");
initializeIdentityWithTokenServerResponse({
status: 500,
headers: [],
@@ -56,13 +55,8 @@ add_task(async function test_findCluster
await Service.identity.initializeWithCurrentIdentity();
await Service.identity.whenReadyToAuthenticate.promise;
cluster = Service._clusterManager._findCluster();
// The cluster manager ensures a trailing "/"
Assert.strictEqual(cluster, endpoint + "/");
Svc.Prefs.resetBranch("");
});
-
-function run_test() {
- initTestLogging();
- run_next_test();
-}
--- a/services/sync/tests/unit/test_history_engine.js
+++ b/services/sync/tests/unit/test_history_engine.js
@@ -1,19 +1,14 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/engines/history.js");
Cu.import("resource://services-common/utils.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
-
-add_task(async function setup() {
- initTestLogging("Trace");
-});
async function rawAddVisit(id, uri, visitPRTime, transitionType) {
return new Promise((resolve, reject) => {
let results = [];
let handler = {
handleResult(result) {
results.push(result);
},
--- a/services/sync/tests/unit/test_history_store.js
+++ b/services/sync/tests/unit/test_history_store.js
@@ -47,21 +47,16 @@ var engine = new HistoryEngine(Service);
Async.promiseSpinningly(engine.initialize());
var store = engine._store;
async function applyEnsureNoFailures(records) {
Assert.equal((await store.applyIncomingBatch(records)).length, 0);
}
var fxuri, fxguid, tburi, tbguid;
-function run_test() {
- initTestLogging("Trace");
- run_next_test();
-}
-
add_task(async function test_store() {
_("Verify that we've got an empty store to work with.");
do_check_empty((await store.getAllIDs()));
_("Let's create an entry in the database.");
fxuri = CommonUtils.makeURI("http://getfirefox.com/");
await PlacesTestUtils.addVisits({ uri: fxuri, title: "Get Firefox!",
--- a/services/sync/tests/unit/test_history_tracker.js
+++ b/services/sync/tests/unit/test_history_tracker.js
@@ -9,18 +9,16 @@ Cu.import("resource://services-sync/cons
Cu.import("resource://services-sync/engines/history.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
let engine;
let tracker;
add_task(async function setup() {
- initTestLogging("Trace");
- Log.repository.getLogger("Sync.Tracker.History").level = Log.Level.Trace;
Service.engineManager.clear();
await Service.engineManager.register(HistoryEngine);
engine = Service.engineManager.get("history");
tracker = engine._tracker;
// Don't write out by default.
tracker.persistChangedIDs = false;
--- a/services/sync/tests/unit/test_hmac_error.js
+++ b/services/sync/tests/unit/test_hmac_error.js
@@ -1,29 +1,29 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/rotaryengine.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
// Track HMAC error counts.
var hmacErrorCount = 0;
(function() {
let hHE = Service.handleHMACEvent;
Service.handleHMACEvent = async function() {
hmacErrorCount++;
return hHE.call(Service);
};
})();
async function shared_setup() {
enableValidationPrefs();
+ syncTestLogging();
hmacErrorCount = 0;
// Make sure RotaryEngine is the only one we sync.
let { engine, tracker } = await registerRotaryEngine();
engine.lastSync = 123; // Needs to be non-zero so that tracker is queried.
engine._store.items = {flying: "LNER Class A3 4472",
scotsman: "Flying Scotsman"};
@@ -231,13 +231,8 @@ add_task(async function hmac_error_durin
},
this);
};
};
onwards();
});
});
-
-function run_test() {
- initTestLogging("Trace");
- run_next_test();
-}
--- a/services/sync/tests/unit/test_httpd_sync_server.js
+++ b/services/sync/tests/unit/test_httpd_sync_server.js
@@ -1,20 +1,14 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-common/utils.js");
Cu.import("resource://services-sync/util.js");
-function run_test() {
- Log.repository.getLogger("Sync.Test.Server").level = Log.Level.Trace;
- initTestLogging();
- run_next_test();
-}
-
add_test(function test_creation() {
// Explicit callback for this one.
let server = new SyncServer({
__proto__: SyncServerCallback,
});
Assert.ok(!!server); // Just so we have a check.
server.start(null, function() {
_("Started on " + server.port);
--- a/services/sync/tests/unit/test_interval_triggers.js
+++ b/services/sync/tests/unit/test_interval_triggers.js
@@ -1,17 +1,16 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-common/utils.js");
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/engines/clients.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
Svc.Prefs.set("registerEngines", "");
Cu.import("resource://services-sync/service.js");
let scheduler;
let clientsEngine;
function sync_httpd_setup() {
@@ -32,29 +31,25 @@ function sync_httpd_setup() {
"/1.1/johndoe/info/collections": collectionsHelper.handler,
"/1.1/johndoe/storage/crypto/keys":
upd("crypto", (new ServerWBO("keys")).handler()),
"/1.1/johndoe/storage/clients": upd("clients", clientsColl.handler())
});
}
async function setUp(server) {
+ syncTestLogging();
await configureIdentity({username: "johndoe"}, server);
await generateNewKeys(Service.collectionKeys);
let serverKeys = Service.collectionKeys.asWBO("crypto", "keys");
await serverKeys.encrypt(Service.identity.syncKeyBundle);
await serverKeys.upload(Service.resource(Service.cryptoKeysURL));
}
add_task(async function setup() {
- initTestLogging("Trace");
-
- Log.repository.getLogger("Sync.Service").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.SyncScheduler").level = Log.Level.Trace;
-
scheduler = Service.scheduler;
clientsEngine = Service.clientsEngine;
// Don't remove stale clients when syncing. This is a test-only workaround
// that lets us add clients directly to the store, without losing them on
// the next sync.
clientsEngine._removeRemoteClient = async (id) => {};
});
--- a/services/sync/tests/unit/test_keys.js
+++ b/services/sync/tests/unit/test_keys.js
@@ -2,17 +2,16 @@
* http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/keys.js");
Cu.import("resource://services-sync/main.js");
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://services-sync/browserid_identity.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
var collectionKeys = new CollectionKeyManager();
function sha256HMAC(message, key) {
let h = Utils.makeHMACHasher(Ci.nsICryptoHMAC.SHA256, key);
return Utils.digestBytes(message, h);
}
--- a/services/sync/tests/unit/test_node_reassignment.js
+++ b/services/sync/tests/unit/test_node_reassignment.js
@@ -6,27 +6,20 @@
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://services-common/rest.js");
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/status.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/rotaryengine.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
Cu.import("resource://gre/modules/PromiseUtils.jsm");
add_task(async function setup() {
- Log.repository.getLogger("Sync.ErrorHandler").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.Resource").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.RESTRequest").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.Service").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.SyncScheduler").level = Log.Level.Trace;
- initTestLogging();
validate_all_future_pings();
// None of the failures in this file should result in a UI error.
function onUIError() {
do_throw("Errors should not be presented in the UI.");
}
Svc.Obs.add("weave:ui:login:error", onUIError);
Svc.Obs.add("weave:ui:sync:error", onUIError);
@@ -51,16 +44,17 @@ function handleReassign(handler, req, re
resp.setHeader("Content-Type", "application/json");
resp.bodyOutputStream.write(reassignBody, reassignBody.length);
}
async function prepareServer() {
let server = new SyncServer();
server.registerUser("johndoe");
server.start();
+ syncTestLogging();
await configureIdentity({username: "johndoe"}, server);
return server;
}
function getReassigned() {
try {
return Services.prefs.getBoolPref("services.sync.lastSyncReassigned");
} catch (ex) {
--- a/services/sync/tests/unit/test_password_engine.js
+++ b/services/sync/tests/unit/test_password_engine.js
@@ -1,12 +1,11 @@
Cu.import("resource://gre/modules/FxAccountsCommon.js");
Cu.import("resource://services-sync/engines/passwords.js");
Cu.import("resource://services-sync/service.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
const LoginInfo = Components.Constructor(
"@mozilla.org/login-manager/loginInfo;1", Ci.nsILoginInfo, "init");
const PropertyBag = Components.Constructor(
"@mozilla.org/hash-property-bag;1", Ci.nsIWritablePropertyBag);
function run_test() {
--- a/services/sync/tests/unit/test_password_store.js
+++ b/services/sync/tests/unit/test_password_store.js
@@ -143,20 +143,16 @@ async function test_apply_same_record_wi
async function test_LoginRec_toString(store, recordData) {
let rec = await store.createRecord(recordData.id);
ok(rec);
ok(!rec.toString().includes(rec.password));
}
add_task(async function run_test() {
- initTestLogging("Trace");
- Log.repository.getLogger("Sync.Engine.Passwords").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.Store.Passwords").level = Log.Level.Trace;
-
const BOGUS_GUID_A = "zzzzzzzzzzzz";
const BOGUS_GUID_B = "yyyyyyyyyyyy";
let recordA = {id: BOGUS_GUID_A,
hostname: "http://foo.bar.com",
formSubmitURL: "http://foo.bar.com/baz",
httpRealm: "secure",
username: "john",
password: "smith",
--- a/services/sync/tests/unit/test_password_tracker.js
+++ b/services/sync/tests/unit/test_password_tracker.js
@@ -7,17 +7,16 @@ Cu.import("resource://services-sync/engi
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
let engine;
let store;
let tracker;
add_task(async function setup() {
- initTestLogging("Trace");
await Service.engineManager.register(PasswordEngine);
engine = Service.engineManager.get("passwords");
store = engine._store;
tracker = engine._tracker;
// Don't do asynchronous writes.
tracker.persistChangedIDs = false;
});
--- a/services/sync/tests/unit/test_postqueue.js
+++ b/services/sync/tests/unit/test_postqueue.js
@@ -1,15 +1,13 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
let { PostQueue } = Cu.import("resource://services-sync/record.js", {});
-initTestLogging("Trace");
-
function makeRecord(nbytes) {
return {
toJSON: () => ({ payload: "x".repeat(nbytes) }),
};
}
// Note: This is 14 bytes. Tests make assumptions about this (even if it's just
// in setting config.max_request_bytes to a specific value).
--- a/services/sync/tests/unit/test_records_crypto.js
+++ b/services/sync/tests/unit/test_records_crypto.js
@@ -3,17 +3,16 @@
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/keys.js");
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/resource.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
var cryptoWrap;
function crypted_resource_handler(metadata, response) {
let obj = {id: "resource",
modified: cryptoWrap.modified,
payload: JSON.stringify(cryptoWrap.payload)};
return httpd_basic_auth_handler(JSON.stringify(obj), metadata, response);
--- a/services/sync/tests/unit/test_records_wbo.js
+++ b/services/sync/tests/unit/test_records_wbo.js
@@ -1,18 +1,15 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/resource.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
-
-initTestLogging("Trace");
add_test(function test_toJSON() {
_("Create a record, for now without a TTL.");
let wbo = new WBORecord("coll", "a_record");
wbo.modified = 12345;
wbo.sortindex = 42;
wbo.payload = {};
--- a/services/sync/tests/unit/test_resource.js
+++ b/services/sync/tests/unit/test_resource.js
@@ -2,17 +2,16 @@
* http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://services-common/observers.js");
Cu.import("resource://services-common/utils.js");
Cu.import("resource://services-sync/resource.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://services-sync/browserid_identity.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
var logger;
var fetched = false;
function server_open(metadata, response) {
let body;
if (metadata.method == "GET") {
fetched = true;
--- a/services/sync/tests/unit/test_resource_header.js
+++ b/services/sync/tests/unit/test_resource_header.js
@@ -1,21 +1,16 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://services-sync/resource.js");
-function run_test() {
- initTestLogging("Trace");
- run_next_test();
-}
-
var httpServer = new HttpServer();
httpServer.registerPathHandler("/content", contentHandler);
httpServer.start(-1);
const HTTP_PORT = httpServer.identity.primaryPort;
const TEST_URL = "http://localhost:" + HTTP_PORT + "/content";
const BODY = "response body";
--- a/services/sync/tests/unit/test_resource_ua.js
+++ b/services/sync/tests/unit/test_resource_ua.js
@@ -1,16 +1,15 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/resource.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
var httpProtocolHandler = Cc["@mozilla.org/network/protocol;1?name=http"]
.getService(Ci.nsIHttpProtocolHandler);
// Tracking info/collections.
var collectionsHelper = track_collections_helper();
var collections = collectionsHelper.collections;
--- a/services/sync/tests/unit/test_score_triggers.js
+++ b/services/sync/tests/unit/test_score_triggers.js
@@ -3,17 +3,16 @@
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/engines/clients.js");
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/status.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/rotaryengine.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
// Tracking info/collections.
var collectionsHelper = track_collections_helper();
var upd = collectionsHelper.with_updated_collection;
function sync_httpd_setup() {
let handlers = {};
@@ -38,24 +37,16 @@ function sync_httpd_setup() {
}
async function setUp(server) {
let engineInfo = await registerRotaryEngine();
await SyncTestingInfrastructure(server, "johndoe", "ilovejane");
return engineInfo;
}
-function run_test() {
- initTestLogging("Trace");
-
- Log.repository.getLogger("Sync.Service").level = Log.Level.Trace;
-
- run_next_test();
-}
-
add_task(async function test_tracker_score_updated() {
enableValidationPrefs();
let { engine, tracker } = await registerRotaryEngine();
let scoreUpdated = 0;
function onScoreUpdated() {
scoreUpdated++;
--- a/services/sync/tests/unit/test_service_attributes.js
+++ b/services/sync/tests/unit/test_service_attributes.js
@@ -1,16 +1,15 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/fakeservices.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
add_task(async function test_urls() {
_("URL related Service properties correspond to preference settings.");
try {
Assert.equal(Service.clusterURL, "");
Assert.ok(!Service.userBaseURL);
Assert.equal(Service.infoURL, undefined);
Assert.equal(Service.storageURL, undefined);
--- a/services/sync/tests/unit/test_service_cluster.js
+++ b/services/sync/tests/unit/test_service_cluster.js
@@ -1,27 +1,27 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://gre/modules/PromiseUtils.jsm");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
function do_check_throws(func) {
var raised = false;
try {
func();
} catch (ex) {
raised = true;
}
Assert.ok(raised);
}
add_test(function test_findCluster() {
+ syncTestLogging();
_("Test Service._findCluster()");
try {
let whenReadyToAuthenticate = PromiseUtils.defer();
Service.identity.whenReadyToAuthenticate = whenReadyToAuthenticate;
whenReadyToAuthenticate.resolve(true);
Service.identity._ensureValidToken = () => Promise.reject(new Error("Connection refused"));
@@ -40,16 +40,17 @@ add_test(function test_findCluster() {
} finally {
Svc.Prefs.resetBranch("");
run_next_test();
}
});
add_test(function test_setCluster() {
+ syncTestLogging();
_("Test Service._setCluster()");
try {
_("Check initial state.");
Assert.equal(Service.clusterURL, "");
Service._clusterManager._findCluster = () => "http://weave.user.node/";
_("Set the cluster URL.");
@@ -65,13 +66,8 @@ add_test(function test_setCluster() {
Assert.ok(!Service._clusterManager.setCluster());
Assert.equal(Service.clusterURL, "http://weave.user.node/");
} finally {
Svc.Prefs.resetBranch("");
run_next_test();
}
});
-
-function run_test() {
- initTestLogging();
- run_next_test();
-}
--- a/services/sync/tests/unit/test_service_detect_upgrade.js
+++ b/services/sync/tests/unit/test_service_detect_upgrade.js
@@ -4,17 +4,16 @@
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/keys.js");
Cu.import("resource://services-sync/engines/tabs.js");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
add_task(async function v4_upgrade() {
enableValidationPrefs();
let clients = new ServerCollection();
let meta_global = new ServerWBO("global");
// Tracking info/collections.
--- a/services/sync/tests/unit/test_service_login.js
+++ b/services/sync/tests/unit/test_service_login.js
@@ -1,17 +1,16 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/policies.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
Log.repository.rootLogger.addAppender(new Log.DumpAppender());
function login_handling(handler) {
return function(request, response) {
if (has_hawk_header(request)) {
handler(request, response);
} else {
--- a/services/sync/tests/unit/test_service_startOver.js
+++ b/services/sync/tests/unit/test_service_startOver.js
@@ -1,18 +1,15 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
-
-initTestLogging("Trace");
function BlaEngine() {
SyncEngine.call(this, "Bla", Service);
}
BlaEngine.prototype = {
__proto__: SyncEngine.prototype,
removed: false,
--- a/services/sync/tests/unit/test_service_startup.js
+++ b/services/sync/tests/unit/test_service_startup.js
@@ -1,23 +1,21 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-common/observers.js");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
Svc.Prefs.set("registerEngines", "Tab,Bookmarks,Form,History");
Cu.import("resource://services-sync/service.js");
function run_test() {
validate_all_future_pings();
_("When imported, Service.onStartup is called");
- initTestLogging("Trace");
let xps = Cc["@mozilla.org/weave/service;1"]
.getService(Ci.nsISupports)
.wrappedJSObject;
Assert.ok(!xps.enabled);
// Test fixtures
Service.identity.username = "johndoe";
--- a/services/sync/tests/unit/test_service_sync_401.js
+++ b/services/sync/tests/unit/test_service_sync_401.js
@@ -1,16 +1,15 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/policies.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
function login_handling(handler) {
return function(request, response) {
if (request.hasHeader("Authorization") &&
request.getHeader("Authorization").includes('Hawk id="id"')) {
handler(request, response);
} else {
let body = "Unauthorized";
--- a/services/sync/tests/unit/test_service_sync_remoteSetup.js
+++ b/services/sync/tests/unit/test_service_sync_remoteSetup.js
@@ -2,17 +2,16 @@
* http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/keys.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/fakeservices.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
add_task(async function run_test() {
enableValidationPrefs();
validate_all_future_pings();
Log.repository.rootLogger.addAppender(new Log.DumpAppender());
let clients = new ServerCollection();
--- a/services/sync/tests/unit/test_service_sync_specified.js
+++ b/services/sync/tests/unit/test_service_sync_specified.js
@@ -2,17 +2,16 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/engines/clients.js");
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
let syncedEngines = [];
function SteamEngine() {
SyncEngine.call(this, "Steam", Service);
}
SteamEngine.prototype = {
__proto__: SyncEngine.prototype,
@@ -65,23 +64,18 @@ async function setUp() {
let server = sync_httpd_setup({
"/1.1/johndoe/storage/meta/global": new ServerWBO("global", {}).handler(),
});
await SyncTestingInfrastructure(server, "johndoe", "ilovejane");
return server;
}
add_task(async function setup() {
- initTestLogging();
Service.engineManager.clear();
-
- initTestLogging("Trace");
validate_all_future_pings();
- Log.repository.getLogger("Sync.Service").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.ErrorHandler").level = Log.Level.Trace;
await Service.engineManager.register(SteamEngine);
await Service.engineManager.register(StirlingEngine);
});
add_task(async function test_noEngines() {
enableValidationPrefs();
--- a/services/sync/tests/unit/test_service_sync_updateEnabledEngines.js
+++ b/services/sync/tests/unit/test_service_sync_updateEnabledEngines.js
@@ -2,17 +2,16 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/engines/clients.js");
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
function QuietStore() {
Store.call("Quiet");
}
QuietStore.prototype = {
async getAllIDs() {
return [];
}
@@ -72,22 +71,17 @@ async function setUp(server) {
await serverKeys.encrypt(Service.identity.syncKeyBundle);
let {success} = await serverKeys.upload(Service.resource(Service.cryptoKeysURL));
ok(success);
}
const PAYLOAD = 42;
add_task(async function setup() {
- initTestLogging();
Service.engineManager.clear();
-
- initTestLogging("Trace");
- Log.repository.getLogger("Sync.Service").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.ErrorHandler").level = Log.Level.Trace;
validate_all_future_pings();
await Service.engineManager.register(SteamEngine);
await Service.engineManager.register(StirlingEngine);
});
add_task(async function test_newAccount() {
enableValidationPrefs();
--- a/services/sync/tests/unit/test_service_verifyLogin.js
+++ b/services/sync/tests/unit/test_service_verifyLogin.js
@@ -1,16 +1,15 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
function login_handling(handler) {
return function(request, response) {
if (has_hawk_header(request)) {
handler(request, response);
} else {
let body = "Unauthorized";
response.setStatusLine(request.httpVersion, 401, "Unauthorized");
--- a/services/sync/tests/unit/test_service_wipeClient.js
+++ b/services/sync/tests/unit/test_service_wipeClient.js
@@ -1,17 +1,16 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/browserid_identity.js");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
function CanDecryptEngine() {
SyncEngine.call(this, "CanDecrypt", Service);
}
CanDecryptEngine.prototype = {
__proto__: SyncEngine.prototype,
// Override these methods with mocks for the test
@@ -42,17 +41,16 @@ CannotDecryptEngine.prototype = {
this.wasWiped = true;
}
};
let canDecryptEngine;
let cannotDecryptEngine;
add_task(async function setup() {
- initTestLogging();
Service.engineManager.clear();
await Service.engineManager.register(CanDecryptEngine);
await Service.engineManager.register(CannotDecryptEngine);
canDecryptEngine = Service.engineManager.get("candecrypt");
cannotDecryptEngine = Service.engineManager.get("cannotdecrypt");
});
@@ -71,13 +69,15 @@ add_task(async function test_withEngineL
} finally {
canDecryptEngine.wasWiped = false;
cannotDecryptEngine.wasWiped = false;
await Service.startOver();
}
});
add_task(async function test_startOver_clears_keys() {
+ syncTestLogging();
await generateNewKeys(Service.collectionKeys);
Assert.ok(!!Service.collectionKeys.keyForCollection());
await Service.startOver();
+ syncTestLogging();
Assert.ok(!Service.collectionKeys.keyForCollection());
});
--- a/services/sync/tests/unit/test_service_wipeServer.js
+++ b/services/sync/tests/unit/test_service_wipeServer.js
@@ -1,13 +1,12 @@
Cu.import("resource://services-sync/util.js");
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/resource.js");
Cu.import("resource://testing-common/services/sync/fakeservices.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
Svc.Prefs.set("registerEngines", "");
Cu.import("resource://services-sync/service.js");
// configure the identity we use for this test.
const identityConfig = makeIdentityConfig({username: "johndoe"});
function FakeCollection() {
@@ -32,22 +31,16 @@ FakeCollection.prototype = {
};
async function setUpTestFixtures(server) {
Service.clusterURL = server.baseURI + "/";
await configureIdentity(identityConfig);
}
-
-function run_test() {
- initTestLogging("Trace");
- run_next_test();
-}
-
add_task(async function test_wipeServer_list_success() {
_("Service.wipeServer() deletes collections given as argument.");
let steam_coll = new FakeCollection();
let diesel_coll = new FakeCollection();
let server = httpd_setup({
"/1.1/johndoe/storage/steam": steam_coll.handler(),
--- a/services/sync/tests/unit/test_status_checkSetup.js
+++ b/services/sync/tests/unit/test_status_checkSetup.js
@@ -1,19 +1,16 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/status.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
add_task(async function test_status_checkSetup() {
- initTestLogging("Trace");
-
try {
_("Ensure fresh config.");
Status._authManager.deleteSyncCredentials();
_("Fresh setup, we're not configured.");
Assert.equal(Status.checkSetup(), CLIENT_NOT_CONFIGURED);
Assert.equal(Status.login, LOGIN_FAILED_NO_USERNAME);
Status.resetSync();
--- a/services/sync/tests/unit/test_syncengine.js
+++ b/services/sync/tests/unit/test_syncengine.js
@@ -1,16 +1,15 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
async function makeSteamEngine() {
let engine = new SyncEngine("Steam", Service);
await engine.initialize();
return engine;
}
async function testSteamEngineStorage(test) {
--- a/services/sync/tests/unit/test_syncengine_sync.js
+++ b/services/sync/tests/unit/test_syncengine_sync.js
@@ -5,17 +5,16 @@ Cu.import("resource://services-sync/cons
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/main.js");
Cu.import("resource://services-sync/policies.js");
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/resource.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/rotaryengine.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
function makeRotaryEngine() {
return new RotaryEngine(Service);
}
async function clean(engine) {
Svc.Prefs.resetBranch("");
Svc.Prefs.set("log.logger.engine.rotary", "Trace");
--- a/services/sync/tests/unit/test_syncscheduler.js
+++ b/services/sync/tests/unit/test_syncscheduler.js
@@ -5,17 +5,16 @@ Cu.import("resource://services-sync/brow
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/engines/clients.js");
Cu.import("resource://services-sync/policies.js");
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/status.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
function CatapultEngine() {
SyncEngine.call(this, "Catapult", Service);
}
CatapultEngine.prototype = {
__proto__: SyncEngine.prototype,
exception: null, // tests fill this in
async _sync() {
@@ -57,33 +56,32 @@ async function setUp(server) {
let result = (await serverKeys.upload(Service.resource(Service.cryptoKeysURL))).success;
return result;
}
async function cleanUpAndGo(server) {
await Async.promiseYield();
await clientsEngine._store.wipe();
await Service.startOver();
+ // Re-enable logging, which we just disabled.
+ syncTestLogging();
if (server) {
await promiseStopServer(server);
}
}
add_task(async function setup() {
await Service.promiseInitialized;
clientsEngine = Service.clientsEngine;
// Don't remove stale clients when syncing. This is a test-only workaround
// that lets us add clients directly to the store, without losing them on
// the next sync.
clientsEngine._removeRemoteClient = async (id) => {};
Service.engineManager.clear();
- initTestLogging("Trace");
- Log.repository.getLogger("Sync.Service").level = Log.Level.Trace;
- Log.repository.getLogger("Sync.scheduler").level = Log.Level.Trace;
validate_all_future_pings();
scheduler.setDefaults();
await Service.engineManager.register(CatapultEngine);
});
add_test(function test_prefAttributes() {
--- a/services/sync/tests/unit/test_tab_engine.js
+++ b/services/sync/tests/unit/test_tab_engine.js
@@ -1,17 +1,16 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/engines/tabs.js");
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
async function getMocks() {
let engine = new TabEngine(Service);
await engine.initialize();
let store = engine._store;
store.getTabState = mockGetTabState;
store.shouldSkipWindow = mockShouldSkipWindow;
return [engine, store];
--- a/services/sync/tests/unit/test_telemetry.js
+++ b/services/sync/tests/unit/test_telemetry.js
@@ -6,17 +6,16 @@ Cu.import("resource://services-common/ut
Cu.import("resource://services-sync/telemetry.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/resource.js");
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/engines/bookmarks.js");
Cu.import("resource://services-sync/engines/clients.js");
-Cu.import("resource://testing-common/services/sync/utils.js");
Cu.import("resource://testing-common/services/sync/fxa_utils.js");
Cu.import("resource://testing-common/services/sync/rotaryengine.js");
Cu.import("resource://gre/modules/osfile.jsm", this);
Cu.import("resource://services-sync/util.js");
function SteamStore(engine) {
@@ -56,23 +55,22 @@ function BogusEngine(service) {
Engine.call(this, "bogus", service);
}
BogusEngine.prototype = Object.create(SteamEngine.prototype);
async function cleanAndGo(engine, server) {
engine._tracker.clearChangedIDs();
Svc.Prefs.resetBranch("");
- Svc.Prefs.set("log.logger.engine.rotary", "Trace");
+ syncTestLogging();
Service.recordManager.clearCache();
await promiseStopServer(server);
}
add_task(async function setup() {
- initTestLogging("Trace");
// Avoid addon manager complaining about not being initialized
Service.engineManager.unregister("addons");
});
add_task(async function test_basic() {
enableValidationPrefs();
let helper = track_collections_helper();
--- a/services/sync/tests/unit/test_utils_json.js
+++ b/services/sync/tests/unit/test_utils_json.js
@@ -1,16 +1,14 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://services-sync/util.js");
-initTestLogging();
-
add_task(async function test_roundtrip() {
_("Do a simple write of an array to json and read");
await Utils.jsonSave("foo", {}, ["v1", "v2"]);
let foo = await Utils.jsonLoad("foo", {});
Assert.equal(typeof foo, "object");
Assert.equal(foo.length, 2);
Assert.equal(foo[0], "v1");
--- a/tools/lint/eslint/modules.json
+++ b/tools/lint/eslint/modules.json
@@ -203,17 +203,17 @@
"tokenserverclient.js": ["TokenServerClient", "TokenServerClientError", "TokenServerClientNetworkError", "TokenServerClientServerError"],
"ToolboxProcess.jsm": ["BrowserToolboxProcess"],
"tps.jsm": ["ACTIONS", "TPS"],
"Translation.jsm": ["Translation", "TranslationTelemetry"],
"Traversal.jsm": ["TraversalRules", "TraversalHelper"],
"UpdateTelemetry.jsm": ["AUSTLMY"],
"UpdateTopLevelContentWindowIDHelper.jsm": ["trackBrowserWindow"],
"util.js": ["getChromeWindow", "Utils", "Svc"],
- "utils.js": ["btoa", "encryptPayload", "makeIdentityConfig", "makeFxAccountsInternalMock", "configureFxAccountIdentity", "configureIdentity", "SyncTestingInfrastructure", "waitForZeroTimer", "Promise", "MockFxaStorageManager", "AccountState", "sumHistogram", "CommonUtils", "CryptoUtils", "TestingUtils", "promiseZeroTimer", "promiseNamedTimer", "getLoginTelemetryScalar"],
+ "utils.js": ["btoa", "encryptPayload", "makeIdentityConfig", "makeFxAccountsInternalMock", "configureFxAccountIdentity", "configureIdentity", "SyncTestingInfrastructure", "waitForZeroTimer", "Promise", "MockFxaStorageManager", "AccountState", "sumHistogram", "CommonUtils", "CryptoUtils", "TestingUtils", "promiseZeroTimer", "promiseNamedTimer", "getLoginTelemetryScalar", "syncTestLogging"],
"Utils.jsm": ["Utils", "Logger", "PivotContext", "PrefCache"],
"VariablesView.jsm": ["VariablesView", "escapeHTML"],
"VariablesViewController.jsm": ["VariablesViewController", "StackFrameUtils"],
"version.jsm": ["VERSION"],
"vtt.jsm": ["WebVTT"],
"WebChannel.jsm": ["WebChannel", "WebChannelBroker"],
"WindowDraggingUtils.jsm": ["WindowDraggingElement"],
"windows.jsm": ["BrowserWindows"],