Bug 1333044 - Enable no-undef eslint rule for services/. r=markh

MozReview-Commit-ID: IrtWclENDth

--HG--
extra : rebase_source : 72df6ddc457431ae77f953a00712462e4902b5f1
This commit is contained in:
Mark Banner 2017-01-23 15:15:05 +00:00
Родитель df3fdf012f
Коммит 8cf0d4744c
35 изменённых файлов: 65 добавлений и 122 удалений

Просмотреть файл

@ -11,5 +11,6 @@ module.exports = {
"consistent-return": "warn",
"no-func-assign": "warn",
"no-nested-ternary": "warn",
"no-undef": "error",
}
};

Просмотреть файл

@ -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;
}
},

Просмотреть файл

@ -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();

Просмотреть файл

@ -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

Просмотреть файл

@ -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);

Просмотреть файл

@ -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");

Просмотреть файл

@ -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"},

Просмотреть файл

@ -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

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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");
});

Просмотреть файл

@ -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;

Просмотреть файл

@ -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 {

Просмотреть файл

@ -1402,4 +1402,4 @@ Sync11Service.prototype = {
};
this.Service = new Sync11Service();
Service.onStartup();
this.Service.onStartup();

Просмотреть файл

@ -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.

Просмотреть файл

@ -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);
}
};
}

Просмотреть файл

@ -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.

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;

Просмотреть файл

@ -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);

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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",

Просмотреть файл

@ -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});
}

Просмотреть файл

@ -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.");

Просмотреть файл

@ -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

Просмотреть файл

@ -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");

Просмотреть файл

@ -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 {

Просмотреть файл

@ -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);

Просмотреть файл

@ -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

Просмотреть файл

@ -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",

Просмотреть файл

@ -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");

Просмотреть файл

@ -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);
},

Просмотреть файл

@ -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,

Просмотреть файл

@ -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"],