author | Dan Banner <dbugs@thebanners.uk> |
Thu, 27 Apr 2017 17:24:18 +0100 | |
changeset 571429 | 5f36dc0913a3cf4bde3119a2208c20cd39a1b031 |
parent 571414 | bfc7b187005cabbc828ed9f5b61daf139c3cfd90 |
child 626758 | 20333ae392694c7c8904cb7526736470d8b9c7d4 |
push id | 56786 |
push user | bmo:dbugs@thebanners.uk |
push date | Tue, 02 May 2017 15:55:02 +0000 |
reviewers | markh |
bugs | 1359540 |
milestone | 55.0a1 |
new file mode 100644 --- /dev/null +++ b/services/.eslintrc.js @@ -0,0 +1,11 @@ +"use strict"; + +module.exports = { + extends: [ + "plugin:mozilla/recommended" + ], + + plugins: [ + "mozilla" + ] +}
--- a/services/crypto/modules/utils.js +++ b/services/crypto/modules/utils.js @@ -506,17 +506,17 @@ this.CryptoUtils = { CryptoUtils.updateUTF8("\n", hasher); let hash = hasher.finish(false); // HAWK specifies this .hash to use +/ (not _-) and include the // trailing "==" padding. let hash_b64 = btoa(hash); artifacts.hash = hash_b64; } - let requestString = ("hawk.1.header" + "\n" + + let requestString = ("hawk.1.header\n" + artifacts.ts.toString(10) + "\n" + artifacts.nonce + "\n" + artifacts.method + "\n" + artifacts.resource + "\n" + artifacts.host + "\n" + artifacts.port + "\n" + (artifacts.hash || "") + "\n"); if (artifacts.ext) {
--- a/services/fxaccounts/FxAccountsManager.jsm +++ b/services/fxaccounts/FxAccountsManager.jsm @@ -460,17 +460,17 @@ this.FxAccountsManager = { if (!aEmail) { return this._error(ERROR_INVALID_EMAIL); } let client = this._getFxAccountsClient(); return client.accountExists(aEmail).then( result => { - log.debug("Account " + result ? "" : "does not" + " exists"); + log.debug("Account " + (result ? "" : "does not ") + "exists"); let error = this._getError(result); if (error) { return this._error(error, result); } return Promise.resolve({ registered: result });
--- a/services/fxaccounts/tests/mochitest/test_invalidEmailCase.html +++ b/services/fxaccounts/tests/mochitest/test_invalidEmailCase.html @@ -33,36 +33,36 @@ Components.utils.import("resource://serv const TEST_SERVER = "http://mochi.test:8888/chrome/services/fxaccounts/tests/mochitest/file_invalidEmailCase.sjs?path="; let MockStorage = function() { this.data = null; }; MockStorage.prototype = Object.freeze({ - set: function (contents) { + set(contents) { this.data = contents; return Promise.resolve(null); }, - get: function () { + get() { return Promise.resolve(this.data); }, getOAuthTokens() { return Promise.resolve(null); }, setOAuthTokens(contents) { return Promise.resolve(); }, }); function MockFxAccounts() { return new FxAccounts({ _now_is: new Date(), - now: function() { + now() { return this._now_is; }, signedInUserStorage: new MockStorage(), fxAccountsClient: new FxAccountsClient(TEST_SERVER), }); } @@ -108,23 +108,22 @@ function runTest() { ok(false, JSON.stringify(setSignedInUserError)); } ); }, signInError => { ok(false, JSON.stringify(signInError)); } ); -}; +} SpecialPowers.pushPrefEnv({"set": [ ["identity.fxaccounts.enabled", true], // fx accounts ["identity.fxaccounts.auth.uri", TEST_SERVER], // our sjs server ["browser.dom.window.dump.enabled", true], ]}, - function () { runTest(); } + function() { runTest(); } ); </script> </pre> </body> </html> -
--- a/services/sync/modules/bookmark_repair.js +++ b/services/sync/modules/bookmark_repair.js @@ -376,17 +376,17 @@ class BookmarkRepairRequestor extends Co break; case STATE.ABORTED: break; // our caller will take the abort action. case STATE.FINISHED: break; - case NOT_REPAIRING: + case STATE.NOT_REPAIRING: // No repair is in progress. This is a common case, so only log trace. log.trace("continue repairs called but no repair in progress."); break; default: log.error(`continue repairs finds itself in an unknown state ${state}`); state = STATE.ABORTED; break; @@ -662,28 +662,26 @@ class BookmarkRepairResponder extends Co if (syncable) { log.debug(`repair request to upload item '${id}' which exists locally; uploading`); toUpload.add(id); } else { // explicitly requested and not syncable, so tombstone. log.debug(`repair request to upload item '${id}' but it isn't under a syncable root; writing a tombstone`); toDelete.add(id); } + // The item wasn't explicitly requested - only upload if it is syncable + // and doesn't exist on the server. + } else if (syncable && !existRemotely.has(id)) { + log.debug(`repair request found related item '${id}' which isn't on the server; uploading`); + toUpload.add(id); + } else if (!syncable && existRemotely.has(id)) { + log.debug(`repair request found non-syncable related item '${id}' on the server; writing a tombstone`); + toDelete.add(id); } else { - // The item wasn't explicitly requested - only upload if it is syncable - // and doesn't exist on the server. - if (syncable && !existRemotely.has(id)) { - log.debug(`repair request found related item '${id}' which isn't on the server; uploading`); - toUpload.add(id); - } else if (!syncable && existRemotely.has(id)) { - log.debug(`repair request found non-syncable related item '${id}' on the server; writing a tombstone`); - toDelete.add(id); - } else { - log.debug(`repair request found related item '${id}' which we will not upload; ignoring`); - } + log.debug(`repair request found related item '${id}' which we will not upload; ignoring`); } } return { toUpload, toDelete }; } onUploaded(subject, data) { if (data != "bookmarks") { return;
--- a/services/sync/modules/bookmark_validator.js +++ b/services/sync/modules/bookmark_validator.js @@ -381,16 +381,18 @@ class BookmarkValidator { * - root: Root of the server-side bookmark tree. Has the same properties as * above. * - deletedRecords: As above, but only contains items that the server sent * where it also sent indication that the item should be deleted. * - problemData: a BookmarkProblemData object, with the caveat that * the fields describing client/server relationship will not have been filled * out yet. */ + // XXX This should be split up and the complexity reduced. + // eslint-disable-next-line complexity async inspectServerRecords(serverRecords) { let deletedItemIds = new Set(); let idToRecord = new Map(); let deletedRecords = []; let folders = []; let problemData = new BookmarkProblemData(); @@ -674,16 +676,18 @@ class BookmarkValidator { * * Returns the same data as described in the inspectServerRecords comment, * with the following additional fields. * - clientRecords: an array of client records in a similar format to * the .records (ie, server records) entry. * - problemData is the same as for inspectServerRecords, except all properties * will be filled out. */ + // XXX This should be split up and the complexity reduced. + // eslint-disable-next-line complexity async compareServerWithClient(serverRecords, clientTree) { let clientRecords = await this.createClientRecordsFromTree(clientTree); let inspectionInfo = await this.inspectServerRecords(serverRecords); inspectionInfo.clientRecords = clientRecords; // Mainly do this to remove deleted items and normalize child guids. serverRecords = inspectionInfo.records;
--- a/services/sync/modules/telemetry.js +++ b/services/sync/modules/telemetry.js @@ -692,9 +692,10 @@ class SyncTelemetryImpl { name: "unexpectederror", // as above, remove the profile dir value. error: String(error).replace(reProfileDir, "[profileDir]") } } } +/* global SyncTelemetry */ this.SyncTelemetry = new SyncTelemetryImpl(ENGINES);
--- a/services/sync/tests/unit/head_helpers.js +++ b/services/sync/tests/unit/head_helpers.js @@ -1,16 +1,15 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ /* import-globals-from head_appinfo.js */ /* import-globals-from ../../../common/tests/unit/head_helpers.js */ - -// From head_http_server.js (which also imports this file). -/* global new_timestamp */ +/* import-globals-from head_errorhandler_common.js */ +/* import-globals-from head_http_server.js */ // This file expects Service to be defined in the global scope when EHTestsCommon // is used (from service.js). /* global Service */ Cu.import("resource://services-common/async.js"); Cu.import("resource://testing-common/services/common/utils.js"); Cu.import("resource://testing-common/PlacesTestUtils.jsm"); @@ -480,16 +479,18 @@ function promiseNextTick() { // Avoid an issue where `client.name2` containing unicode characters causes // a number of tests to fail, due to them assuming that we do not need to utf-8 // encode or decode data sent through the mocked server (see bug 1268912). Utils.getDefaultDeviceName = function() { return "Test device name"; }; function registerRotaryEngine() { + let {RotaryEngine} = + Cu.import("resource://testing-common/services/sync/rotaryengine.js", {}); Service.engineManager.clear(); Service.engineManager.register(RotaryEngine); let engine = Service.engineManager.get("rotary"); engine.enabled = true; return { engine, tracker: engine._tracker }; }
--- a/services/sync/tests/unit/test_bookmark_repair.js +++ b/services/sync/tests/unit/test_bookmark_repair.js @@ -308,19 +308,16 @@ add_task(async function test_bookmark_re add_task(async function test_repair_client_missing() { enableValidationPrefs(); _("Ensure that a record missing from the client only will get re-downloaded from the server"); let server = serverForFoo(bookmarksEngine); await SyncTestingInfrastructure(server); - let user = server.user("foo"); - - let initialID = Service.clientsEngine.localID; let remoteID = Utils.makeGUID(); try { _("Syncing to initialize crypto etc."); Service.sync(); _("Create remote client record"); server.insertWBO("foo", "clients", new ServerWBO(remoteID, encryptPayload({ @@ -382,17 +379,16 @@ add_task(async function test_repair_serv _("Ensure that a record missing from the server only will get re-upload from the client"); let server = serverForFoo(bookmarksEngine); await SyncTestingInfrastructure(server); let user = server.user("foo"); - let initialID = Service.clientsEngine.localID; let remoteID = Utils.makeGUID(); try { _("Syncing to initialize crypto etc."); Service.sync(); _("Create remote client record"); server.insertWBO("foo", "clients", new ServerWBO(remoteID, encryptPayload({ @@ -445,19 +441,16 @@ add_task(async function test_repair_serv add_task(async function test_repair_server_deleted() { enableValidationPrefs(); _("Ensure that a record marked as deleted on the server but present on the client will get deleted on the client"); let server = serverForFoo(bookmarksEngine); await SyncTestingInfrastructure(server); - let user = server.user("foo"); - - let initialID = Service.clientsEngine.localID; let remoteID = Utils.makeGUID(); try { _("Syncing to initialize crypto etc."); Service.sync(); _("Create remote client record"); server.insertWBO("foo", "clients", new ServerWBO(remoteID, encryptPayload({
--- a/services/sync/tests/unit/test_clients_engine.js +++ b/services/sync/tests/unit/test_clients_engine.js @@ -786,17 +786,16 @@ add_task(async function test_clients_not _("Ensure that clients not in the FxA devices list are marked as stale."); engine._store.wipe(); generateNewKeys(Service.collectionKeys); let server = serverForFoo(engine); await SyncTestingInfrastructure(server); - let user = server.user("foo"); let remoteId = Utils.makeGUID(); let remoteId2 = Utils.makeGUID(); _("Create remote client records"); server.insertWBO("foo", "clients", new ServerWBO(remoteId, encryptPayload({ id: remoteId, name: "Remote client", type: "desktop",
--- a/services/sync/tests/unit/test_errorhandler_filelog.js +++ b/services/sync/tests/unit/test_errorhandler_filelog.js @@ -268,17 +268,16 @@ add_test(function test_login_error_logOn setLastSync(PROLONGED_ERROR_DURATION); Svc.Obs.notify("weave:service:login:error"); }); add_test(function test_noNewFailed_noErrorLog() { Svc.Prefs.set("log.appender.file.logOnError", true); Svc.Prefs.set("log.appender.file.logOnSuccess", false); - let log = Log.repository.getLogger("Sync.Test.FileLog"); Svc.Obs.add("weave:service:reset-file-log", function onResetFileLog() { Svc.Obs.remove("weave:service:reset-file-log", onResetFileLog); // No log file was written. do_check_false(logsdir.directoryEntries.hasMoreElements()); Svc.Prefs.resetBranch(""); run_next_test(); });
--- a/services/sync/tests/unit/test_telemetry.js +++ b/services/sync/tests/unit/test_telemetry.js @@ -386,17 +386,16 @@ add_task(async function test_engine_fail }); add_task(async function test_initial_sync_engines() { enableValidationPrefs(); Service.engineManager.register(SteamEngine); let engine = Service.engineManager.get("steam"); engine.enabled = true; - let engines = {}; // These are the only ones who actually have things to sync at startup. let engineNames = ["clients", "bookmarks", "prefs", "tabs"]; let server = serverForEnginesWithKeys({"foo": "password"}, ["bookmarks", "prefs", "tabs"].map(name => Service.engineManager.get(name) )); await SyncTestingInfrastructure(server); try { _(`test_initial_sync_engines: Steam tracker contents: ${
--- a/tools/lint/eslint/modules.json +++ b/tools/lint/eslint/modules.json @@ -33,17 +33,17 @@ "CloudSyncBookmarksFolderCache.jsm": ["FolderCache"], "CloudSyncEventSource.jsm": ["EventSource"], "CloudSyncLocal.jsm": ["Local"], "CloudSyncPlacesWrapper.jsm": ["PlacesWrapper"], "CloudSyncTabs.jsm": ["Tabs"], "collection_repair.js": ["getRepairRequestor", "getAllRepairRequestors", "CollectionRepairRequestor", "getRepairResponder", "CollectionRepairResponder"], "collection_validator.js": ["CollectionValidator", "CollectionProblemData"], "Console.jsm": ["console", "ConsoleAPI"], - "constants.js": ["WEAVE_VERSION", "SYNC_API_VERSION", "USER_API_VERSION", "MISC_API_VERSION", "STORAGE_VERSION", "PREFS_BRANCH", "PWDMGR_HOST", "PWDMGR_PASSWORD_REALM", "PWDMGR_PASSPHRASE_REALM", "PWDMGR_KEYBUNDLE_REALM", "DEFAULT_KEYBUNDLE_NAME", "HMAC_INPUT", "SYNC_KEY_ENCODED_LENGTH", "SYNC_KEY_DECODED_LENGTH", "SYNC_KEY_HYPHENATED_LENGTH", "NO_SYNC_NODE_INTERVAL", "MAX_ERROR_COUNT_BEFORE_BACKOFF", "MAX_IGNORE_ERROR_COUNT", "MINIMUM_BACKOFF_INTERVAL", "MAXIMUM_BACKOFF_INTERVAL", "HMAC_EVENT_INTERVAL", "MASTER_PASSWORD_LOCKED_RETRY_INTERVAL", "DEFAULT_BLOCK_PERIOD", "MOBILE_BATCH_SIZE", "DEFAULT_GUID_FETCH_BATCH_SIZE", "DEFAULT_MOBILE_GUID_FETCH_BATCH_SIZE", "DEFAULT_STORE_BATCH_SIZE", "HISTORY_STORE_BATCH_SIZE", "FORMS_STORE_BATCH_SIZE", "PASSWORDS_STORE_BATCH_SIZE", "ADDONS_STORE_BATCH_SIZE", "APPS_STORE_BATCH_SIZE", "DEFAULT_DOWNLOAD_BATCH_SIZE", "SINGLE_USER_THRESHOLD", "MULTI_DEVICE_THRESHOLD", "SCORE_INCREMENT_SMALL", "SCORE_INCREMENT_MEDIUM", "SCORE_INCREMENT_XLARGE", "SCORE_UPDATE_DELAY", "IDLE_OBSERVER_BACK_DELAY", "MAX_UPLOAD_RECORDS", "MAX_UPLOAD_BYTES", "MAX_HISTORY_UPLOAD", "MAX_HISTORY_DOWNLOAD", "NOTIFY_TAB_SENT_TTL_SECS", "STATUS_OK", "SYNC_FAILED", "LOGIN_FAILED", "SYNC_FAILED_PARTIAL", "CLIENT_NOT_CONFIGURED", "STATUS_DISABLED", "MASTER_PASSWORD_LOCKED", "LOGIN_SUCCEEDED", "SYNC_SUCCEEDED", "ENGINE_SUCCEEDED", "LOGIN_FAILED_NO_USERNAME", "LOGIN_FAILED_NO_PASSWORD", "LOGIN_FAILED_NO_PASSPHRASE", "LOGIN_FAILED_NETWORK_ERROR", "LOGIN_FAILED_SERVER_ERROR", "LOGIN_FAILED_INVALID_PASSPHRASE", "LOGIN_FAILED_LOGIN_REJECTED", "METARECORD_DOWNLOAD_FAIL", "VERSION_OUT_OF_DATE", "DESKTOP_VERSION_OUT_OF_DATE", "SETUP_FAILED_NO_PASSPHRASE", "CREDENTIALS_CHANGED", "ABORT_SYNC_COMMAND", "NO_SYNC_NODE_FOUND", "OVER_QUOTA", "PROLONGED_SYNC_FAILURE", "SERVER_MAINTENANCE", "RESPONSE_OVER_QUOTA", "ENGINE_UPLOAD_FAIL", "ENGINE_DOWNLOAD_FAIL", "ENGINE_UNKNOWN_FAIL", "ENGINE_APPLY_FAIL", "ENGINE_METARECORD_DOWNLOAD_FAIL", "ENGINE_METARECORD_UPLOAD_FAIL", "ENGINE_BATCH_INTERRUPTED", "JPAKE_ERROR_CHANNEL", "JPAKE_ERROR_NETWORK", "JPAKE_ERROR_SERVER", "JPAKE_ERROR_TIMEOUT", "JPAKE_ERROR_INTERNAL", "JPAKE_ERROR_INVALID", "JPAKE_ERROR_NODATA", "JPAKE_ERROR_KEYMISMATCH", "JPAKE_ERROR_WRONGMESSAGE", "JPAKE_ERROR_USERABORT", "JPAKE_ERROR_DELAYUNSUPPORTED", "INFO_COLLECTIONS", "INFO_COLLECTION_USAGE", "INFO_COLLECTION_COUNTS", "INFO_QUOTA", "kSyncMasterPasswordLocked", "kSyncWeaveDisabled", "kSyncNetworkOffline", "kSyncBackoffNotMet", "kFirstSyncChoiceNotMade", "FIREFOX_ID", "FENNEC_ID", "SEAMONKEY_ID", "TEST_HARNESS_ID", "MIN_PP_LENGTH", "MIN_PASS_LENGTH", "DEVICE_TYPE_DESKTOP", "DEVICE_TYPE_MOBILE", "SQLITE_MAX_VARIABLE_NUMBER"], + "constants.js": ["WEAVE_VERSION", "SYNC_API_VERSION", "USER_API_VERSION", "MISC_API_VERSION", "STORAGE_VERSION", "PREFS_BRANCH", "PWDMGR_HOST", "PWDMGR_PASSWORD_REALM", "PWDMGR_PASSPHRASE_REALM", "PWDMGR_KEYBUNDLE_REALM", "DEFAULT_KEYBUNDLE_NAME", "HMAC_INPUT", "SYNC_KEY_ENCODED_LENGTH", "SYNC_KEY_DECODED_LENGTH", "SYNC_KEY_HYPHENATED_LENGTH", "NO_SYNC_NODE_INTERVAL", "MAX_ERROR_COUNT_BEFORE_BACKOFF", "MAX_IGNORE_ERROR_COUNT", "MINIMUM_BACKOFF_INTERVAL", "MAXIMUM_BACKOFF_INTERVAL", "HMAC_EVENT_INTERVAL", "MASTER_PASSWORD_LOCKED_RETRY_INTERVAL", "DEFAULT_BLOCK_PERIOD", "MOBILE_BATCH_SIZE", "DEFAULT_GUID_FETCH_BATCH_SIZE", "DEFAULT_MOBILE_GUID_FETCH_BATCH_SIZE", "DEFAULT_STORE_BATCH_SIZE", "HISTORY_STORE_BATCH_SIZE", "FORMS_STORE_BATCH_SIZE", "PASSWORDS_STORE_BATCH_SIZE", "ADDONS_STORE_BATCH_SIZE", "APPS_STORE_BATCH_SIZE", "DEFAULT_DOWNLOAD_BATCH_SIZE", "DEFAULT_MAX_RECORD_PAYLOAD_BYTES", "SINGLE_USER_THRESHOLD", "MULTI_DEVICE_THRESHOLD", "SCORE_INCREMENT_SMALL", "SCORE_INCREMENT_MEDIUM", "SCORE_INCREMENT_XLARGE", "SCORE_UPDATE_DELAY", "IDLE_OBSERVER_BACK_DELAY", "MAX_UPLOAD_RECORDS", "MAX_UPLOAD_BYTES", "MAX_HISTORY_UPLOAD", "MAX_HISTORY_DOWNLOAD", "NOTIFY_TAB_SENT_TTL_SECS", "STATUS_OK", "SYNC_FAILED", "LOGIN_FAILED", "SYNC_FAILED_PARTIAL", "CLIENT_NOT_CONFIGURED", "STATUS_DISABLED", "MASTER_PASSWORD_LOCKED", "LOGIN_SUCCEEDED", "SYNC_SUCCEEDED", "ENGINE_SUCCEEDED", "LOGIN_FAILED_NO_USERNAME", "LOGIN_FAILED_NO_PASSWORD", "LOGIN_FAILED_NO_PASSPHRASE", "LOGIN_FAILED_NETWORK_ERROR", "LOGIN_FAILED_SERVER_ERROR", "LOGIN_FAILED_INVALID_PASSPHRASE", "LOGIN_FAILED_LOGIN_REJECTED", "METARECORD_DOWNLOAD_FAIL", "VERSION_OUT_OF_DATE", "DESKTOP_VERSION_OUT_OF_DATE", "SETUP_FAILED_NO_PASSPHRASE", "CREDENTIALS_CHANGED", "ABORT_SYNC_COMMAND", "NO_SYNC_NODE_FOUND", "OVER_QUOTA", "PROLONGED_SYNC_FAILURE", "SERVER_MAINTENANCE", "RESPONSE_OVER_QUOTA", "ENGINE_UPLOAD_FAIL", "ENGINE_DOWNLOAD_FAIL", "ENGINE_UNKNOWN_FAIL", "ENGINE_APPLY_FAIL", "ENGINE_METARECORD_DOWNLOAD_FAIL", "ENGINE_METARECORD_UPLOAD_FAIL", "ENGINE_BATCH_INTERRUPTED", "JPAKE_ERROR_CHANNEL", "JPAKE_ERROR_NETWORK", "JPAKE_ERROR_SERVER", "JPAKE_ERROR_TIMEOUT", "JPAKE_ERROR_INTERNAL", "JPAKE_ERROR_INVALID", "JPAKE_ERROR_NODATA", "JPAKE_ERROR_KEYMISMATCH", "JPAKE_ERROR_WRONGMESSAGE", "JPAKE_ERROR_USERABORT", "JPAKE_ERROR_DELAYUNSUPPORTED", "INFO_COLLECTIONS", "INFO_COLLECTION_USAGE", "INFO_COLLECTION_COUNTS", "INFO_QUOTA", "kSyncMasterPasswordLocked", "kSyncWeaveDisabled", "kSyncNetworkOffline", "kSyncBackoffNotMet", "kFirstSyncChoiceNotMade", "FIREFOX_ID", "FENNEC_ID", "SEAMONKEY_ID", "TEST_HARNESS_ID", "MIN_PP_LENGTH", "MIN_PASS_LENGTH", "DEVICE_TYPE_DESKTOP", "DEVICE_TYPE_MOBILE", "SQLITE_MAX_VARIABLE_NUMBER"], "Constants.jsm": ["Roles", "Events", "Relations", "Filters", "States", "Prefilters"], "ContactDB.jsm": ["ContactDB", "DB_NAME", "STORE_NAME", "SAVED_GETALL_STORE_NAME", "REVISION_STORE", "DB_VERSION"], "content-server.jsm": ["init"], "content.jsm": ["registerContentFrame"], "ContentCrashHandlers.jsm": ["TabCrashHandler", "PluginCrashReporter", "UnsubmittedCrashHandler"], "ContentObservers.js": [], "ContentPrefUtils.jsm": ["ContentPref", "cbHandleResult", "cbHandleError", "cbHandleCompletion", "safeCallback", "_methodsCallableFromChild"], "controller.js": ["MozMillController", "globalEventRegistry", "sleep", "windowMap"],