From 8cf0d4744cb936eb45bfe6972e6cf67e45f3d5f2 Mon Sep 17 00:00:00 2001 From: Mark Banner Date: Mon, 23 Jan 2017 15:15:05 +0000 Subject: [PATCH] Bug 1333044 - Enable no-undef eslint rule for services/. r=markh MozReview-Commit-ID: IrtWclENDth --HG-- extra : rebase_source : 72df6ddc457431ae77f953a00712462e4902b5f1 --- services/.eslintrc.js | 1 + .../common/modules-testing/storageserver.js | 12 +++--- services/common/tests/run_storage_server.js | 4 ++ .../tests/unit/test_blocklist_certificates.js | 2 +- services/common/tests/unit/test_hawkclient.js | 2 +- .../common/tests/unit/test_restrequest.js | 2 +- .../common/tests/unit/test_storage_adapter.js | 4 +- services/common/utils.js | 14 ------- services/crypto/modules/utils.js | 4 +- services/crypto/tests/unit/head_helpers.js | 2 +- services/crypto/tests/unit/test_jwcrypto.js | 4 +- .../tests/xpcshell/test_accounts.js | 2 +- .../fxaccounts/tests/xpcshell/test_client.js | 3 +- services/sync/modules/rest.js | 2 +- services/sync/modules/service.js | 2 +- services/sync/modules/stages/enginesync.js | 2 +- .../sync/tests/unit/fake_login_manager.js | 38 ------------------- .../tests/unit/head_errorhandler_common.js | 7 ++++ services/sync/tests/unit/head_helpers.js | 9 +++++ services/sync/tests/unit/head_http_server.js | 1 + .../tests/unit/test_bookmark_livemarks.js | 2 +- .../unit/test_bookmark_smart_bookmarks.js | 1 - .../sync/tests/unit/test_bookmark_tracker.js | 31 --------------- .../sync/tests/unit/test_forms_tracker.js | 2 +- .../tests/unit/test_fxa_service_cluster.js | 2 +- services/sync/tests/unit/test_hmac_error.js | 6 +-- services/sync/tests/unit/test_resource.js | 3 +- .../sync/tests/unit/test_syncscheduler.js | 2 +- .../tests/unit/test_syncstoragerequest.js | 1 + services/sync/tests/unit/xpcshell.ini | 1 - .../extensions/tps/components/tps-cmdline.js | 2 +- .../tps/resource/modules/bookmarks.jsm | 10 ++--- .../sync/tps/extensions/tps/resource/tps.jsm | 2 + testing/mochitest/chrome.eslintrc.js | 2 + tools/lint/eslint/modules.json | 3 +- 35 files changed, 65 insertions(+), 122 deletions(-) delete mode 100644 services/sync/tests/unit/fake_login_manager.js diff --git a/services/.eslintrc.js b/services/.eslintrc.js index 951feed69617..82ade1238609 100644 --- a/services/.eslintrc.js +++ b/services/.eslintrc.js @@ -11,5 +11,6 @@ module.exports = { "consistent-return": "warn", "no-func-assign": "warn", "no-nested-ternary": "warn", + "no-undef": "error", } }; diff --git a/services/common/modules-testing/storageserver.js b/services/common/modules-testing/storageserver.js index a3c0f0541b16..1d4851c1e662 100644 --- a/services/common/modules-testing/storageserver.js +++ b/services/common/modules-testing/storageserver.js @@ -928,12 +928,12 @@ StorageServer.prototype = { cb(); } } catch (ex) { - _("=========================================="); - _("Got exception starting Storage HTTP server on port " + this.port); - _("Error: " + Log.exceptionStr(ex)); - _("Is there a process already listening on port " + this.port + "?"); - _("=========================================="); - do_throw(ex); + this._log.error("=========================================="); + this._log.error("Got exception starting Storage HTTP server on port " + this.port); + this._log.error("Error: " + Log.exceptionStr(ex)); + this._log.error("Is there a process already listening on port " + this.port + "?"); + this._log.error("=========================================="); + throw ex; } }, diff --git a/services/common/tests/run_storage_server.js b/services/common/tests/run_storage_server.js index a6a80f9d3f04..342663235032 100644 --- a/services/common/tests/run_storage_server.js +++ b/services/common/tests/run_storage_server.js @@ -12,6 +12,10 @@ * $ make storage-server */ +// Disable eslint no-undef rule for this file, as it is simple and is complicated +// to check all the imports. +/* eslint no-undef:off */ + Cu.import("resource://testing-common/services/common/storageserver.js"); initTestLogging(); diff --git a/services/common/tests/unit/test_blocklist_certificates.js b/services/common/tests/unit/test_blocklist_certificates.js index cf5ee9d03889..96e6cec10fcf 100644 --- a/services/common/tests/unit/test_blocklist_certificates.js +++ b/services/common/tests/unit/test_blocklist_certificates.js @@ -75,7 +75,7 @@ add_task(function* test_something() { yield sqliteHandle.close(); // Test the db is updated when we call again with a later lastModified value - result = yield OneCRLBlocklistClient.maybeSync(4000, Date.now()); + yield OneCRLBlocklistClient.maybeSync(4000, Date.now()); // Open the collection, verify it's been updated: // Our test data now has two records; both should be in the local collection diff --git a/services/common/tests/unit/test_hawkclient.js b/services/common/tests/unit/test_hawkclient.js index aea0b29389dd..619183f45b00 100644 --- a/services/common/tests/unit/test_hawkclient.js +++ b/services/common/tests/unit/test_hawkclient.js @@ -384,7 +384,7 @@ add_task(function* test_500_no_retry() { let method = "GET"; let server = httpd_setup({ - "/no-shutup": function() { + "/no-shutup": function(request, response) { let message = "Cannot get ye flask."; response.setStatusLine(request.httpVersion, 500, "Internal server error"); response.bodyOutputStream.write(message, message.length); diff --git a/services/common/tests/unit/test_restrequest.js b/services/common/tests/unit/test_restrequest.js index a5bf93e2ec09..e7ea85e7e1fc 100644 --- a/services/common/tests/unit/test_restrequest.js +++ b/services/common/tests/unit/test_restrequest.js @@ -772,7 +772,7 @@ add_test(function test_exception_in_onProgress() { let request = new RESTRequest(server.baseURI + "/resource"); request.onProgress = function onProgress() { - it.does.not.exist(); + it.does.not.exist(); // eslint-disable-line no-undef }; request.get(function onComplete(error) { do_check_eq(error, "ReferenceError: it is not defined"); diff --git a/services/common/tests/unit/test_storage_adapter.js b/services/common/tests/unit/test_storage_adapter.js index 676e35b315b3..7691e5dc4662 100644 --- a/services/common/tests/unit/test_storage_adapter.js +++ b/services/common/tests/unit/test_storage_adapter.js @@ -127,7 +127,7 @@ function test_collection_operations() { error = e; } do_check_neq(error, null); - records = yield adapter.list(); + let records = yield adapter.list(); do_check_eq(records.length, 0); yield sqliteHandle.close(); }); @@ -179,7 +179,7 @@ function test_collection_operations() { let sqliteHandle = yield do_get_kinto_connection(); let adapter = do_get_kinto_adapter(sqliteHandle); yield adapter.clear(); - records = yield adapter.list(); + let records = yield adapter.list(); do_check_eq(records.length, 0); let impactedRecords = yield adapter.loadDump([ {id: 1, foo: "bar"}, diff --git a/services/common/utils.js b/services/common/utils.js index 34d987c9a961..56db9089e1a9 100644 --- a/services/common/utils.js +++ b/services/common/utils.js @@ -131,20 +131,6 @@ this.CommonUtils = { return deferred.promise; }, - /** - * Spin the event loop and return once the next tick is executed. - * - * This is an evil function and should not be used in production code. It - * exists in this module for ease-of-use. - */ - waitForNextTick: function waitForNextTick() { - let cb = Async.makeSyncCallback(); - this.nextTick(cb); - Async.waitForSyncCallback(cb); - - - }, - /** * Return a timer that is scheduled to call the callback after waiting the * provided time or as soon as possible. The timer will be set as a property diff --git a/services/crypto/modules/utils.js b/services/crypto/modules/utils.js index 4c095134bfc6..3547d110c86d 100644 --- a/services/crypto/modules/utils.js +++ b/services/crypto/modules/utils.js @@ -9,7 +9,6 @@ this.EXPORTED_SYMBOLS = ["CryptoUtils"]; Cu.import("resource://services-common/observers.js"); Cu.import("resource://services-common/utils.js"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://services-sync/constants.js"); this.CryptoUtils = { xor: function xor(a, b) { @@ -187,9 +186,8 @@ this.CryptoUtils = { hmacAlg = Ci.nsICryptoHMAC.SHA1, hmacLen = 20) { // We don't have a default in the algo itself, as NSS does. - // Use the constant. if (!dkLen) { - dkLen = SYNC_KEY_DECODED_LENGTH; + throw new Error("dkLen should be defined"); } function F(S, c, i, h) { diff --git a/services/crypto/tests/unit/head_helpers.js b/services/crypto/tests/unit/head_helpers.js index 5791fbd1a66e..13a4358ba440 100644 --- a/services/crypto/tests/unit/head_helpers.js +++ b/services/crypto/tests/unit/head_helpers.js @@ -47,7 +47,7 @@ function base64UrlDecode(s) { s += "="; break; // One pad char default: - throw new InputException("Illegal base64url string!"); + throw new Error("Illegal base64url string!"); } // With correct padding restored, apply the standard base64 decoder diff --git a/services/crypto/tests/unit/test_jwcrypto.js b/services/crypto/tests/unit/test_jwcrypto.js index 071f3123ba85..fe91e4bac645 100644 --- a/services/crypto/tests/unit/test_jwcrypto.js +++ b/services/crypto/tests/unit/test_jwcrypto.js @@ -62,7 +62,7 @@ function test_rsa() { do_test_pending(); function checkRSA(err, kpo) { do_check_neq(kpo, undefined); - log(kpo.serializedPublicKey); + do_print(kpo.serializedPublicKey); let pk = JSON.parse(kpo.serializedPublicKey); do_check_eq(pk.algorithm, "RS"); /* TODO @@ -92,7 +92,7 @@ function test_dsa() { do_test_pending(); function checkDSA(err, kpo) { do_check_neq(kpo, undefined); - log(kpo.serializedPublicKey); + do_print(kpo.serializedPublicKey); let pk = JSON.parse(kpo.serializedPublicKey); do_check_eq(pk.algorithm, "DS"); /* TODO diff --git a/services/fxaccounts/tests/xpcshell/test_accounts.js b/services/fxaccounts/tests/xpcshell/test_accounts.js index d723863ec07b..924e1d86ef4f 100644 --- a/services/fxaccounts/tests/xpcshell/test_accounts.js +++ b/services/fxaccounts/tests/xpcshell/test_accounts.js @@ -209,7 +209,7 @@ add_task(function* test_non_https_remote_server_uri() { Services.prefs.setCharPref( "identity.fxaccounts.remote.signup.uri", "http://example.com/browser/browser/base/content/test/general/accounts_testRemoteCommands.html"); - rejects(fxAccounts.promiseAccountsSignUpURI(), null, "Firefox Accounts server must use HTTPS"); + Assert.rejects(fxAccounts.promiseAccountsSignUpURI(), null, "Firefox Accounts server must use HTTPS"); Services.prefs.clearUserPref("identity.fxaccounts.remote.signup.uri"); }); diff --git a/services/fxaccounts/tests/xpcshell/test_client.js b/services/fxaccounts/tests/xpcshell/test_client.js index c1caf454d56c..1f19169aa634 100644 --- a/services/fxaccounts/tests/xpcshell/test_client.js +++ b/services/fxaccounts/tests/xpcshell/test_client.js @@ -742,6 +742,7 @@ add_task(function* test_updateDevice() { add_task(function* test_signOutAndDestroyDevice() { const DEVICE_ID = "device id"; const ERROR_ID = "test that the client promise rejects"; + let emptyMessage = "{}"; const server = httpd_setup({ "/account/device/destroy": function(request, response) { @@ -835,7 +836,7 @@ add_task(function* test_client_metrics() { let client = new FxAccountsClient(server.baseURI); - yield rejects(client.signOut(FAKE_SESSION_TOKEN, { + yield Assert.rejects(client.signOut(FAKE_SESSION_TOKEN, { service: "sync", }), function(err) { return err.errno == 111; diff --git a/services/sync/modules/rest.js b/services/sync/modules/rest.js index 8579086a919e..02450c0cc676 100644 --- a/services/sync/modules/rest.js +++ b/services/sync/modules/rest.js @@ -42,7 +42,7 @@ SyncStorageRequest.prototype = { let result = this.authenticator(this, method); if (result && result.headers) { for (let [k, v] of Object.entries(result.headers)) { - setHeader(k, v); + this.setHeader(k, v); } } } else { diff --git a/services/sync/modules/service.js b/services/sync/modules/service.js index 83a7f3f6d212..7422361c1c46 100644 --- a/services/sync/modules/service.js +++ b/services/sync/modules/service.js @@ -1402,4 +1402,4 @@ Sync11Service.prototype = { }; this.Service = new Sync11Service(); -Service.onStartup(); +this.Service.onStartup(); diff --git a/services/sync/modules/stages/enginesync.js b/services/sync/modules/stages/enginesync.js index 580f3ded852d..b174acee45c2 100644 --- a/services/sync/modules/stages/enginesync.js +++ b/services/sync/modules/stages/enginesync.js @@ -260,7 +260,7 @@ EngineSynchronizer.prototype = { let infoResp = this.service._fetchInfo(collectionCountsURL); if (!infoResp.success) { this._log.error("Can't run validation: request to info/collection_counts responded with " - + resp.status); + + infoResp.status); return; } info = infoResp.obj; // might throw because obj is a getter which parses json. diff --git a/services/sync/tests/unit/fake_login_manager.js b/services/sync/tests/unit/fake_login_manager.js deleted file mode 100644 index cae126514c37..000000000000 --- a/services/sync/tests/unit/fake_login_manager.js +++ /dev/null @@ -1,38 +0,0 @@ -Cu.import("resource://services-sync/util.js"); - -// ---------------------------------------- -// Fake Sample Data -// ---------------------------------------- - -var fakeSampleLogins = [ - // Fake nsILoginInfo object. - {hostname: "www.boogle.com", - formSubmitURL: "http://www.boogle.com/search", - httpRealm: "", - username: "", - password: "", - usernameField: "test_person", - passwordField: "test_password"} -]; - -// ---------------------------------------- -// Fake Login Manager -// ---------------------------------------- - -function FakeLoginManager(fakeLogins) { - this.fakeLogins = fakeLogins; - - let self = this; - - // Use a fake nsILoginManager object. - delete Services.logins; - Services.logins = { - removeAllLogins() { self.fakeLogins = []; }, - getAllLogins() { return self.fakeLogins; }, - addLogin(login) { - getTestLogger().info("nsILoginManager.addLogin() called " + - "with hostname '" + login.hostname + "'."); - self.fakeLogins.push(login); - } - }; -} diff --git a/services/sync/tests/unit/head_errorhandler_common.js b/services/sync/tests/unit/head_errorhandler_common.js index 7bd27dbbf55f..78f37f82b6de 100644 --- a/services/sync/tests/unit/head_errorhandler_common.js +++ b/services/sync/tests/unit/head_errorhandler_common.js @@ -3,9 +3,16 @@ /* import-globals-from head_appinfo.js */ /* import-globals-from ../../../common/tests/unit/head_helpers.js */ +/* import-globals-from head_helpers.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-sync/engines.js"); +Cu.import("resource://services-sync/constants.js"); +Cu.import("resource://services-sync/keys.js"); // Common code for test_errorhandler_{1,2}.js -- pulled out to make it less // monolithic and take less time to execute. diff --git a/services/sync/tests/unit/head_helpers.js b/services/sync/tests/unit/head_helpers.js index f1651183a94d..a312c22d19d5 100644 --- a/services/sync/tests/unit/head_helpers.js +++ b/services/sync/tests/unit/head_helpers.js @@ -4,6 +4,13 @@ /* 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 */ + +// 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"); @@ -75,6 +82,7 @@ function loadAddonTestFunctions() { const path = ExtensionsTestPath("/head_addons.js"); let file = do_get_file(path); let uri = Services.io.newFileURI(file); + /* import-globals-from ../../../../toolkit/mozapps/extensions/test/xpcshell/head_addons.js */ Services.scriptloader.loadSubScript(uri.spec, gGlobalScope); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); } @@ -91,6 +99,7 @@ function webExtensionsTestPath(path) { * Loads the WebExtension test functions by importing its test file. */ function loadWebExtensionTestFunctions() { + /* import-globals-from ../../../../toolkit/components/extensions/test/xpcshell/head_sync.js */ const path = webExtensionsTestPath("/head_sync.js"); let file = do_get_file(path); let uri = Services.io.newFileURI(file); diff --git a/services/sync/tests/unit/head_http_server.js b/services/sync/tests/unit/head_http_server.js index 8df1ecb5f550..a219507aabcb 100644 --- a/services/sync/tests/unit/head_http_server.js +++ b/services/sync/tests/unit/head_http_server.js @@ -1,5 +1,6 @@ /* import-globals-from head_appinfo.js */ /* import-globals-from ../../../common/tests/unit/head_helpers.js */ +/* import-globals-from head_helpers.js */ var Cm = Components.manager; diff --git a/services/sync/tests/unit/test_bookmark_livemarks.js b/services/sync/tests/unit/test_bookmark_livemarks.js index 8adde76d8468..caddef4b7fcc 100644 --- a/services/sync/tests/unit/test_bookmark_livemarks.js +++ b/services/sync/tests/unit/test_bookmark_livemarks.js @@ -110,7 +110,7 @@ add_test(function test_livemark_invalid() { do_check_eq(-1, store.idForGUID(parentGUID)); store.create(lateParentRec); - recID = store.idForGUID(lateParentRec.id, true); + let recID = store.idForGUID(lateParentRec.id, true); do_check_true(recID > 0); do_check_eq(PlacesUtils.bookmarks.getFolderIdForItem(recID), PlacesUtils.bookmarks.unfiledBookmarksFolder); diff --git a/services/sync/tests/unit/test_bookmark_smart_bookmarks.js b/services/sync/tests/unit/test_bookmark_smart_bookmarks.js index 48bd60391634..1f152ded9d98 100644 --- a/services/sync/tests/unit/test_bookmark_smart_bookmarks.js +++ b/services/sync/tests/unit/test_bookmark_smart_bookmarks.js @@ -44,7 +44,6 @@ function clearBookmarks() { PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.bookmarks.tagsFolder); PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.bookmarks.toolbarFolder); PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.bookmarks.unfiledBookmarksFolder); - startCount = smartBookmarkCount(); } function serverForFoo(engineData) { diff --git a/services/sync/tests/unit/test_bookmark_tracker.js b/services/sync/tests/unit/test_bookmark_tracker.js index 94b9afe9902b..ad3b25a13bf4 100644 --- a/services/sync/tests/unit/test_bookmark_tracker.js +++ b/services/sync/tests/unit/test_bookmark_tracker.js @@ -97,37 +97,6 @@ async function dumpBookmarks() { }) } -var populateTree = async function populate(parentId, ...items) { - let guids = {}; - for (let item of items) { - let itemId; - switch (item.type) { - case PlacesUtils.bookmarks.TYPE_BOOKMARK: - itemId = PlacesUtils.bookmarks.insertBookmark(parentId, - Utils.makeURI(item.url), - PlacesUtils.bookmarks.DEFAULT_INDEX, item.title); - break; - - case PlacesUtils.bookmarks.TYPE_FOLDER: { - itemId = PlacesUtils.bookmarks.createFolder(parentId, - item.title, PlacesUtils.bookmarks.DEFAULT_INDEX); - Object.assign(guids, await populate(itemId, ...item.children)); - break; - } - - default: - throw new Error(`Unsupported item type: ${item.type}`); - } - if (item.exclude) { - PlacesUtils.annotations.setItemAnnotation( - itemId, BookmarkAnnos.EXCLUDEBACKUP_ANNO, "Don't back this up", 0, - PlacesUtils.annotations.EXPIRE_NEVER); - } - guids[item.title] = await PlacesUtils.promiseItemGuid(itemId); - } - return guids; -} - async function insertBookmarksToMigrate() { await PlacesUtils.bookmarks.insert({ guid: "0gtWTOgYcoJD", diff --git a/services/sync/tests/unit/test_forms_tracker.js b/services/sync/tests/unit/test_forms_tracker.js index 08912e36183a..d3530002e570 100644 --- a/services/sync/tests/unit/test_forms_tracker.js +++ b/services/sync/tests/unit/test_forms_tracker.js @@ -20,7 +20,7 @@ function run_test() { engine._store.create({name, value}); } function removeEntry(name, value) { - guid = engine._findDupe({name, value}); + let guid = engine._findDupe({name, value}); engine._store.remove({id: guid}); } diff --git a/services/sync/tests/unit/test_fxa_service_cluster.js b/services/sync/tests/unit/test_fxa_service_cluster.js index fb2548fc40bb..1993623ddd37 100644 --- a/services/sync/tests/unit/test_fxa_service_cluster.js +++ b/services/sync/tests/unit/test_fxa_service_cluster.js @@ -35,7 +35,7 @@ add_task(async function test_findCluster() { await Assert.rejects(Service.identity.whenReadyToAuthenticate.promise, "should reject due to 401"); - cluster = Service._clusterManager._findCluster(); + let cluster = Service._clusterManager._findCluster(); Assert.strictEqual(cluster, null); _("_findCluster() works with correct tokenserver response."); diff --git a/services/sync/tests/unit/test_hmac_error.js b/services/sync/tests/unit/test_hmac_error.js index 98f8af4442ca..ea6202d891ae 100644 --- a/services/sync/tests/unit/test_hmac_error.js +++ b/services/sync/tests/unit/test_hmac_error.js @@ -198,9 +198,9 @@ add_task(async function hmac_error_during_node_reassignment() { _("---------------------------"); onSyncFinished = function() { _("== Second (automatic) sync done."); - hasData = rotaryColl.wbo("flying") || - rotaryColl.wbo("scotsman"); - hasKeys = keysWBO.modified; + let hasData = rotaryColl.wbo("flying") || + rotaryColl.wbo("scotsman"); + let hasKeys = keysWBO.modified; do_check_true(!hasData == !hasKeys); // Kick off another sync. Can't just call it, because we're inside the diff --git a/services/sync/tests/unit/test_resource.js b/services/sync/tests/unit/test_resource.js index 94e1b628f90a..b52bd94c2adf 100644 --- a/services/sync/tests/unit/test_resource.js +++ b/services/sync/tests/unit/test_resource.js @@ -450,7 +450,7 @@ function run_test() { throw "BOO!"; }; res18._onProgress = onProgress; - oldWarn = res18._log.warn; + let oldWarn = res18._log.warn; warnings = []; res18._log.warn = function(msg) { warnings.push(msg) }; error = undefined; @@ -468,6 +468,7 @@ function run_test() { "Got exception calling onProgress handler during fetch of " + server.baseURI + "/json"); + res18._log.warn = oldWarn; _("Ensure channel timeouts are thrown appropriately."); let res19 = new Resource(server.baseURI + "/json"); diff --git a/services/sync/tests/unit/test_syncscheduler.js b/services/sync/tests/unit/test_syncscheduler.js index a3f0d5455afc..031b07165334 100644 --- a/services/sync/tests/unit/test_syncscheduler.js +++ b/services/sync/tests/unit/test_syncscheduler.js @@ -693,7 +693,7 @@ add_task(async function test_no_sync_node() { let server = sync_httpd_setup(); await setUp(server); - oldfc = Service._clusterManager._findCluster; + let oldfc = Service._clusterManager._findCluster; Service._clusterManager._findCluster = () => null; Service.clusterURL = ""; try { diff --git a/services/sync/tests/unit/test_syncstoragerequest.js b/services/sync/tests/unit/test_syncstoragerequest.js index 427965e7b12e..d6e0fed85569 100644 --- a/services/sync/tests/unit/test_syncstoragerequest.js +++ b/services/sync/tests/unit/test_syncstoragerequest.js @@ -173,6 +173,7 @@ add_test(function test_weave_quota_error() { }); add_test(function test_abort() { + const TIMESTAMP = 1274380462; function handler(request, response) { response.setHeader("X-Weave-Timestamp", "" + TIMESTAMP, false); response.setHeader("X-Weave-Quota-Remaining", "1048576", false); diff --git a/services/sync/tests/unit/xpcshell.ini b/services/sync/tests/unit/xpcshell.ini index 169a842178f5..0757a290959f 100644 --- a/services/sync/tests/unit/xpcshell.ini +++ b/services/sync/tests/unit/xpcshell.ini @@ -4,7 +4,6 @@ firefox-appdir = browser support-files = addon1-search.xml bootstrap1-search.xml - fake_login_manager.js missing-sourceuri.xml missing-xpi-search.xml places_v10_from_v11.sqlite diff --git a/services/sync/tps/extensions/tps/components/tps-cmdline.js b/services/sync/tps/extensions/tps/components/tps-cmdline.js index edca331c0dc4..45038421d4cc 100644 --- a/services/sync/tps/extensions/tps/components/tps-cmdline.js +++ b/services/sync/tps/extensions/tps/components/tps-cmdline.js @@ -114,7 +114,7 @@ var TPSCmdLineModule = { compMgr = compMgr.QueryInterface(nsIComponentRegistrar); compMgr.unregisterFactoryLocation(TPS_CMDLINE_CLSID, fileSpec); - catman = Components.classes[CATMAN_CONTRACTID].getService(nsICategoryManager); + let catman = Components.classes[CATMAN_CONTRACTID].getService(nsICategoryManager); catman.deleteCategoryEntry("command-line-argument-handlers", "TPS command line handler", true); catman.deleteCategoryEntry("command-line-handler", diff --git a/services/sync/tps/extensions/tps/resource/modules/bookmarks.jsm b/services/sync/tps/extensions/tps/resource/modules/bookmarks.jsm index bbc7a43303c4..afb3490d0b86 100644 --- a/services/sync/tps/extensions/tps/resource/modules/bookmarks.jsm +++ b/services/sync/tps/extensions/tps/resource/modules/bookmarks.jsm @@ -263,7 +263,7 @@ PlacesItem.prototype = { * @return the folder id if the folder was found or created, otherwise -1 */ GetOrCreateFolder(location) { - folder_id = this.GetFolder(location); + let folder_id = this.GetFolder(location); if (folder_id == -1) folder_id = this.CreateFolder(location); return folder_id; @@ -784,7 +784,7 @@ Livemark.prototype = { PlacesUtils.livemarks.addLivemark(livemarkObj).then( aLivemark => { spinningCb(null, [Components.results.NS_OK, aLivemark]) }, - () => { spinningCb(null, [Components.results.NS_ERROR_UNEXPECTED, aLivemark]) } + () => { spinningCb(null, [Components.results.NS_ERROR_UNEXPECTED, null]) } ); let [status, livemark] = spinningCb.wait(); @@ -933,9 +933,9 @@ Separator.prototype = { } let expected_pos = -1; if (this.props.before) { - other_id = this.GetPlacesNodeId(this.props.folder_id, - null, - this.props.before); + let other_id = this.GetPlacesNodeId(this.props.folder_id, + null, + this.props.before); if (other_id == -1) { Logger.logPotentialError("Can't find places item " + this.props.before + " for locating separator"); diff --git a/services/sync/tps/extensions/tps/resource/tps.jsm b/services/sync/tps/extensions/tps/resource/tps.jsm index 39bb11688bc1..94411ec12d61 100644 --- a/services/sync/tps/extensions/tps/resource/tps.jsm +++ b/services/sync/tps/extensions/tps/resource/tps.jsm @@ -137,6 +137,8 @@ var TPS = { // Configure some logging prefs for Sync itself. Weave.Svc.Prefs.set("log.appender.dump", "Debug"); + + /* global Authentication */ Cu.import("resource://tps/auth/fxaccounts.jsm", module); }, diff --git a/testing/mochitest/chrome.eslintrc.js b/testing/mochitest/chrome.eslintrc.js index 23feffb8631e..d9705828fbf3 100644 --- a/testing/mochitest/chrome.eslintrc.js +++ b/testing/mochitest/chrome.eslintrc.js @@ -2,6 +2,7 @@ module.exports = { rules: { "mozilla/import-headjs-globals": "warn", + "mozilla/import-browserjs-globals": "warn", "mozilla/import-test-globals": "warn", "mozilla/mark-test-function-used": "warn", }, @@ -17,6 +18,7 @@ module.exports = { "add_task": false, "addLoadEvent": false, "Assert": false, + "BrowserTestUtils": false, "EventUtils": false, "executeSoon": false, "export_assertions": false, diff --git a/tools/lint/eslint/modules.json b/tools/lint/eslint/modules.json index c53694e08436..11b5324e5ce6 100644 --- a/tools/lint/eslint/modules.json +++ b/tools/lint/eslint/modules.json @@ -70,6 +70,7 @@ "EventUtils.js": ["disableNonTestMouseEvents", "sendMouseEvent", "sendChar", "sendString", "sendKey", "synthesizeMouse", "synthesizeTouch", "synthesizeMouseAtPoint", "synthesizeTouchAtPoint", "synthesizeMouseAtCenter", "synthesizeTouchAtCenter", "synthesizeWheel", "synthesizeKey", "synthesizeMouseExpectEvent", "synthesizeKeyExpectEvent", "synthesizeText", "synthesizeComposition", "synthesizeQuerySelectedText"], "Extension.jsm": ["Extension", "ExtensionData"], "ExtensionAPI.jsm": ["ExtensionAPI", "ExtensionAPIs"], + "extension-storage.js": ["ExtensionStorageEngine", "EncryptionRemoteTransformer", "KeyRingEncryptionRemoteTransformer"], "ExtensionXPCShellUtils.jsm": ["ExtensionTestUtils"], "fakeservices.js": ["FakeCryptoService", "FakeFilesystemService", "FakeGUIDService", "fakeSHA256HMAC"], "file_expandosharing.jsm": ["checkFromJSM"], @@ -222,7 +223,7 @@ "Traversal.jsm": ["TraversalRules", "TraversalHelper"], "UpdateTelemetry.jsm": ["AUSTLMY"], "util.js": ["getChromeWindow", "XPCOMUtils", "Services", "Utils", "Async", "Svc", "Str"], - "utils.js": ["applicationName", "assert", "Copy", "getBrowserObject", "getChromeWindow", "getWindows", "getWindowByTitle", "getWindowByType", "getWindowId", "getMethodInWindows", "getPreference", "saveDataURL", "setPreference", "sleep", "startTimer", "stopTimer", "takeScreenshot", "unwrapNode", "waitFor", "btoa", "encryptPayload", "makeIdentityConfig", "makeFxAccountsInternalMock", "configureFxAccountIdentity", "configureIdentity", "SyncTestingInfrastructure", "waitForZeroTimer", "Promise", "MockFxaStorageManager", "AccountState", "sumHistogram", "CommonUtils", "CryptoUtils", "TestingUtils"], + "utils.js": ["applicationName", "assert", "Copy", "getBrowserObject", "getChromeWindow", "getWindows", "getWindowByTitle", "getWindowByType", "getWindowId", "getMethodInWindows", "getPreference", "saveDataURL", "setPreference", "sleep", "startTimer", "stopTimer", "takeScreenshot", "unwrapNode", "waitFor", "btoa", "encryptPayload", "makeIdentityConfig", "makeFxAccountsInternalMock", "configureFxAccountIdentity", "configureIdentity", "SyncTestingInfrastructure", "waitForZeroTimer", "Promise", "MockFxaStorageManager", "AccountState", "sumHistogram", "CommonUtils", "CryptoUtils", "TestingUtils", "promiseZeroTimer", "promiseNamedTimer"], "Utils.jsm": ["Utils", "Logger", "PivotContext", "PrefCache"], "VariablesView.jsm": ["VariablesView", "escapeHTML"], "VariablesViewController.jsm": ["VariablesViewController", "StackFrameUtils"],