Bug 1299984 - Enable eslint no-unused-vars for shipping pwmgr code. r=johannh
I also fixed two test cases while I was looking at the results.
MozReview-Commit-ID: LpUj56UNV3r
--- a/toolkit/components/passwordmgr/.eslintrc
+++ b/toolkit/components/passwordmgr/.eslintrc
@@ -4,10 +4,13 @@
// Require spacing around =>
"arrow-spacing": 2,
// No space before always a space after a comma
"comma-spacing": [2, {"before": false, "after": true}],
// Commas at the end of the line not the start
"comma-style": 2,
+
+ // Don't allow unused local variables unless they match the pattern
+ "no-unused-vars": [2, {"args": "none", "vars": "local", "varsIgnorePattern": "^(ids|ignored|unused)$"}],
}
}
--- a/toolkit/components/passwordmgr/InsecurePasswordUtils.jsm
+++ b/toolkit/components/passwordmgr/InsecurePasswordUtils.jsm
@@ -96,17 +96,16 @@ this.InsecurePasswordUtils = {
isSafePage = false;
}
let isFormSubmitHTTP = false, isFormSubmitSecure = false;
if (aForm.rootElement instanceof Ci.nsIDOMHTMLFormElement) {
let uri = Services.io.newURI(aForm.rootElement.action || aForm.rootElement.baseURI,
null, null);
let principal = gScriptSecurityManager.getCodebasePrincipal(uri);
- let host = uri.host;
if (uri.schemeIs("http")) {
isFormSubmitHTTP = true;
if (gContentSecurityManager.isOriginPotentiallyTrustworthy(principal)) {
isFormSubmitSecure = true;
} else if (isSafePage) {
// Only warn about the action if we didn't already warn about the form being insecure.
this._sendWebConsoleMessage("InsecureFormActionPasswordsPresent", domDoc);
--- a/toolkit/components/passwordmgr/LoginImport.jsm
+++ b/toolkit/components/passwordmgr/LoginImport.jsm
@@ -157,17 +157,16 @@ this.LoginImport.prototype = {
} catch (ex) {
Cu.reportError("Error importing login: " + ex);
}
}
rows = yield connection.execute("SELECT * FROM moz_disabledHosts");
for (let row of rows) {
try {
- let id = row.getResultByName("id");
let hostname = row.getResultByName("hostname");
this.store.data.disabledHosts.push(hostname);
} catch (ex) {
Cu.reportError("Error importing disabled host: " + ex);
}
}
} finally {
--- a/toolkit/components/passwordmgr/LoginManagerContent.jsm
+++ b/toolkit/components/passwordmgr/LoginManagerContent.jsm
@@ -1184,17 +1184,17 @@ var LoginManagerContent = {
let form = FormLikeFactory.createFromField(aField);
let doc = aField.ownerDocument;
let messageManager = messageManagerFromWindow(doc.defaultView);
let recipes = messageManager.sendSyncMessage("RemoteLogins:findRecipes", {
formOrigin: LoginUtils._getPasswordOrigin(doc.documentURI),
})[0];
- let [usernameField, newPasswordField, oldPasswordField] =
+ let [usernameField, newPasswordField] =
this._getFormFields(form, false, recipes);
// If we are not verifying a password field, we want
// to use aField as the username field.
if (aField.type != "password") {
usernameField = aField;
}
--- a/toolkit/components/passwordmgr/LoginRecipes.jsm
+++ b/toolkit/components/passwordmgr/LoginRecipes.jsm
@@ -186,17 +186,16 @@ var LoginRecipesContent = {
/**
* @param {Set} aRecipes - Possible recipes that could apply to the form
* @param {FormLike} aForm - We use a form instead of just a URL so we can later apply
* tests to the page contents.
* @return {Set} a subset of recipes that apply to the form with the order preserved
*/
_filterRecipesForForm(aRecipes, aForm) {
let formDocURL = aForm.ownerDocument.location;
- let host = formDocURL.host;
let hostRecipes = aRecipes;
let recipes = new Set();
log.debug("_filterRecipesForForm", aRecipes);
if (!hostRecipes) {
return recipes;
}
for (let hostRecipe of hostRecipes) {
--- a/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
+++ b/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
@@ -926,17 +926,16 @@ LoginManagerPrompter.prototype = {
Services.logins.setLoginSavingEnabled(login.hostname, false);
browser.focus();
}
}] : null;
let usernamePlaceholder = this._getLocalizedString("noUsernamePlaceholder");
let togglePasswordLabel = this._getLocalizedString("togglePasswordLabel");
let togglePasswordAccessKey = this._getLocalizedString("togglePasswordAccessKey");
- let displayHost = this._getShortDisplayHost(login.hostname);
this._getPopupNote().show(
browser,
"password",
promptMsg,
"password-notification-icon",
mainAction,
secondaryActions,
@@ -1279,17 +1278,16 @@ LoginManagerPrompter.prototype = {
* Note: The caller doesn't know the username for aNewLogin, so this
* function fills in .username and .usernameField with the values
* from the login selected by the user.
*
* Note; XPCOM stupidity: |count| is just |logins.length|.
*/
promptToChangePasswordWithUsernames : function (logins, count, aNewLogin) {
this.log("promptToChangePasswordWithUsernames with count:", count);
- const buttonFlags = Ci.nsIPrompt.STD_YES_NO_BUTTONS;
var usernames = logins.map(l => l.username);
var dialogText = this._getLocalizedString("userSelectText");
var dialogTitle = this._getLocalizedString("passwordChangeTitle");
var selectedIndex = { value: null };
// If user selects ok, outparam.value is set to the index
// of the selected username.
--- a/toolkit/components/passwordmgr/storage-json.js
+++ b/toolkit/components/passwordmgr/storage-json.js
@@ -279,18 +279,16 @@ this.LoginManagerStorage_json.prototype
* is an array of encrypted nsLoginInfo and ids is an array of associated
* ids in the database.
*/
_searchLogins(matchData, aOptions = {
schemeUpgrades: false,
}) {
this._store.ensureDataReady();
- let conditions = [];
-
function match(aLogin) {
for (let field in matchData) {
let wantedValue = matchData[field];
switch (field) {
case "formSubmitURL":
if (wantedValue != null) {
// Historical compatibility requires this special case
if (aLogin.formSubmitURL == "") {
@@ -393,17 +391,16 @@ this.LoginManagerStorage_json.prototype
logins = this._decryptLogins(logins);
this.log("_findLogins: returning", logins.length, "logins");
count.value = logins.length; // needed for XPCOM
return logins;
},
countLogins(hostname, formSubmitURL, httpRealm) {
- let count = {};
let loginData = {
hostname: hostname,
formSubmitURL: formSubmitURL,
httpRealm: httpRealm
};
let matchData = { };
for (let field of ["hostname", "formSubmitURL", "httpRealm"])
if (loginData[field] != '')
--- a/toolkit/components/passwordmgr/test/.eslintrc
+++ b/toolkit/components/passwordmgr/test/.eslintrc
@@ -1,6 +1,9 @@
{
"extends": [
"../../../../testing/mochitest/mochitest.eslintrc",
"../../../../testing/mochitest/chrome.eslintrc"
- ]
+ ],
+ "rules": {
+ "no-unused-vars": 0,
+ },
}
--- a/toolkit/components/passwordmgr/test/mochitest/test_passwords_in_type_password.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_passwords_in_type_password.html
@@ -86,18 +86,16 @@ runChecksAfterCommonInit(() => startTest
/** Test for Login Manager: 242956 (Stored password is inserted into a
readable text input on a second page) **/
// Make sure that pwmgr only puts passwords into type=password <input>s.
// Might as well test the converse, too (username in password field).
function startTest() {
- var form, input;
-
is($_(1, "uname").value, "", "Checking for unfilled username 1");
is($_(1, "pword").value, "", "Checking for unfilled password 1");
is($_(2, "uname").value, "testpass", "Checking for password not username 2");
is($_(2, "pword").value, "", "Checking for unfilled password 2");
is($_(3, "uname").value, "", "Checking for unfilled username 3");
is($_(3, "pword").value, "testuser", "Checking for unfilled password 3");
--- a/toolkit/components/passwordmgr/test/unit/test_module_LoginImport.js
+++ b/toolkit/components/passwordmgr/test/unit/test_module_LoginImport.js
@@ -176,17 +176,16 @@ add_task(function* test_import()
/**
* Tests imports of NULL values due to a downgraded database.
*/
add_task(function* test_import_downgraded()
{
let store = new LoginStore(getTempFile("test-import-downgraded.json").path);
let loginsSqlite = getTempFile("test-logins-downgraded.sqlite").path;
- let loginList = TestData.loginList();
// Create and populate the SQLite database first.
let connection = yield Sqlite.openConnection({ path: loginsSqlite });
try {
yield promiseCreateDatabaseSchema(connection);
yield connection.setSchemaVersion(3);
yield promiseInsertLoginInfo(connection, TestData.formLogin({
guid: gUUIDGenerator.generateUUID().toString(),