Bug 1243182 - Enable eslint "space-infix-ops" rule for PSM. r=keeler

Also includes minor cleanups.
This commit is contained in:
Cykesiopka 2016-02-06 21:05:02 -08:00
parent c2fb2b442e
commit 997aa149d8
17 changed files with 116 additions and 119 deletions

View File

@ -111,6 +111,9 @@
// No space padding in parentheses
"space-in-parens": [2, "never"],
// Require spaces around operators
"space-infix-ops": 2,
// Require spaces after return, throw and case
"space-return-throw-case": 2,

View File

@ -80,9 +80,8 @@ function LoadCerts()
function enableBackupAllButton()
{
var rowCnt = userTreeView.rowCount;
var backupAllButton=document.getElementById('mine_backupAllButton');
backupAllButton.disabled = (rowCnt < 1);
let backupAllButton = document.getElementById("mine_backupAllButton");
backupAllButton.disabled = userTreeView.rowCount < 1;
}
function getSelectedCerts()
@ -109,13 +108,13 @@ function getSelectedCerts()
var nr = 0;
if (items != null) nr = items.getRangeCount();
if (nr > 0) {
for (var i=0; i<nr; i++) {
for (let i = 0; i < nr; i++) {
var o1 = {};
var o2 = {};
items.getRangeAt(i, o1, o2);
var min = o1.value;
var max = o2.value;
for (var j=min; j<=max; j++) {
for (let j = min; j <= max; j++) {
if (ca_tab.selected) {
cert = caTreeView.getCert(j);
} else if (mine_tab.selected) {
@ -163,13 +162,13 @@ function getSelectedTreeItems()
var nr = 0;
if (items != null) nr = items.getRangeCount();
if (nr > 0) {
for (var i=0; i<nr; i++) {
for (let i = 0; i < nr; i++) {
var o1 = {};
var o2 = {};
items.getRangeAt(i, o1, o2);
var min = o1.value;
var max = o2.value;
for (var j=min; j<=max; j++) {
for (let j = min; j <= max; j++) {
if (ca_tab.selected) {
tree_item = caTreeView.getTreeItem(j);
} else if (mine_tab.selected) {
@ -223,66 +222,72 @@ function nothingOrContainerSelected(certTree)
return false;
}
/**
* Enables or disables buttons corresponding to a cert tree depending on what
* is selected in the cert tree.
*
* @param {nsICertTree} certTree
* @param {Array} idList A list of string identifiers for button elements to
* enable or disable.
*/
function enableButtonsForCertTree(certTree, idList)
{
let disableButtons = nothingOrContainerSelected(certTree);
for (let id of idList) {
document.getElementById(id).setAttribute("disabled", disableButtons);
}
}
function ca_enableButtons()
{
var disableButtons = nothingOrContainerSelected(caTreeView);
var enableViewButton=document.getElementById('ca_viewButton');
enableViewButton.setAttribute("disabled", disableButtons);
var enableEditButton=document.getElementById('ca_editButton');
enableEditButton.setAttribute("disabled", disableButtons);
var enableExportButton=document.getElementById('ca_exportButton');
enableExportButton.setAttribute("disabled", disableButtons);
var enableDeleteButton=document.getElementById('ca_deleteButton');
enableDeleteButton.setAttribute("disabled", disableButtons);
let idList = [
"ca_viewButton",
"ca_editButton",
"ca_exportButton",
"ca_deleteButton",
];
enableButtonsForCertTree(caTreeView, idList);
}
function mine_enableButtons()
{
var disableButtons = nothingOrContainerSelected(userTreeView);
var enableViewButton=document.getElementById('mine_viewButton');
enableViewButton.setAttribute("disabled", disableButtons);
var enableBackupButton=document.getElementById('mine_backupButton');
enableBackupButton.setAttribute("disabled", disableButtons);
var enableDeleteButton=document.getElementById('mine_deleteButton');
enableDeleteButton.setAttribute("disabled", disableButtons);
let idList = [
"mine_viewButton",
"mine_backupButton",
"mine_deleteButton",
];
enableButtonsForCertTree(userTreeView, idList);
}
function websites_enableButtons()
{
var disableButtons = nothingOrContainerSelected(serverTreeView);
var enableViewButton=document.getElementById('websites_viewButton');
enableViewButton.setAttribute("disabled", disableButtons);
var enableExportButton=document.getElementById('websites_exportButton');
enableExportButton.setAttribute("disabled", disableButtons);
var enableDeleteButton=document.getElementById('websites_deleteButton');
enableDeleteButton.setAttribute("disabled", disableButtons);
let idList = [
"websites_viewButton",
"websites_exportButton",
"websites_deleteButton",
];
enableButtonsForCertTree(serverTreeView, idList);
}
function email_enableButtons()
{
var disableButtons = nothingOrContainerSelected(emailTreeView);
var enableViewButton=document.getElementById('email_viewButton');
enableViewButton.setAttribute("disabled", disableButtons);
var enableExportButton=document.getElementById('email_exportButton');
enableExportButton.setAttribute("disabled", disableButtons);
var enableDeleteButton=document.getElementById('email_deleteButton');
enableDeleteButton.setAttribute("disabled", disableButtons);
let idList = [
"email_viewButton",
"email_exportButton",
"email_deleteButton",
];
enableButtonsForCertTree(emailTreeView, idList);
}
function orphan_enableButtons()
{
var disableButtons = nothingOrContainerSelected(orphanTreeView);
var enableViewButton=document.getElementById('orphan_viewButton');
enableViewButton.setAttribute("disabled", disableButtons);
var enableExportButton=document.getElementById('orphan_exportButton');
enableExportButton.setAttribute("disabled", disableButtons);
var enableDeleteButton=document.getElementById('orphan_deleteButton');
enableDeleteButton.setAttribute("disabled", disableButtons);
let idList = [
"orphan_viewButton",
"orphan_exportButton",
"orphan_deleteButton",
];
enableButtonsForCertTree(orphanTreeView, idList);
}
function backupCerts()
@ -316,11 +321,8 @@ function backupAllCerts()
function editCerts()
{
getSelectedCerts();
var numcerts = selected_certs.length;
if (!numcerts)
return;
for (var t=0; t<numcerts; t++) {
var cert = selected_certs[t];
for (let cert of selected_certs) {
window.openDialog("chrome://pippki/content/editcacert.xul", cert.dbKey,
"chrome,centerscreen,modal");
}
@ -384,12 +386,9 @@ function restoreCerts()
function exportCerts()
{
getSelectedCerts();
var numcerts = selected_certs.length;
if (!numcerts)
return;
for (var t=0; t<numcerts; t++) {
exportToFile(window, selected_certs[t]);
for (let cert of selected_certs) {
exportToFile(window, cert);
}
}
@ -468,12 +467,9 @@ function deleteCerts()
function viewCerts()
{
getSelectedCerts();
var numcerts = selected_certs.length;
if (!numcerts)
return;
for (var t=0; t<numcerts; t++) {
viewCertHelper(window, selected_certs[t]);
for (let cert of selected_certs) {
viewCertHelper(window, cert);
}
}

View File

@ -38,12 +38,13 @@ function onLoad()
function setDetails()
{
var selItem = document.getElementById("nicknames").value;
if (!selItem.length)
let selItem = document.getElementById("nicknames").value;
if (selItem.length == 0) {
return;
}
var index = parseInt(selItem);
var details = dialogParams.GetString(index+itemCount);
let index = parseInt(selItem);
let details = dialogParams.GetString(index + itemCount);
document.getElementById("details").value = details;
}

View File

@ -11,19 +11,19 @@ var dialogParams;
function onLoad()
{
dialogParams = window.arguments[0].QueryInterface(nsIDialogParamBlock);
var selectElement = document.getElementById("tokens");
var aCount = dialogParams.GetInt(0);
for (var i=0; i < aCount; i++) {
var menuItemNode = document.createElement("menuitem");
var token = dialogParams.GetString(i);
menuItemNode.setAttribute("value", token);
menuItemNode.setAttribute("label", token);
selectElement.firstChild.appendChild(menuItemNode);
if (i == 0) {
selectElement.selectedItem = menuItemNode;
}
dialogParams = window.arguments[0].QueryInterface(nsIDialogParamBlock);
let selectElement = document.getElementById("tokens");
let count = dialogParams.GetInt(0);
for (let i = 0; i < count; i++) {
let menuItemNode = document.createElement("menuitem");
let token = dialogParams.GetString(i);
menuItemNode.setAttribute("value", token);
menuItemNode.setAttribute("label", token);
selectElement.firstChild.appendChild(menuItemNode);
if (i == 0) {
selectElement.selectedItem = menuItemNode;
}
}
}
function doOK()

View File

@ -52,9 +52,9 @@ function onLoad()
var selectElement = document.getElementById("nicknames");
itemCount = dialogParams.GetInt(0);
for (var i=0; i < itemCount; i++) {
for (let i = 0; i < itemCount; i++) {
var menuItemNode = document.createElement("menuitem");
var nick = dialogParams.GetString(i+3);
let nick = dialogParams.GetString(i + 3);
menuItemNode.setAttribute("value", i);
menuItemNode.setAttribute("label", nick); // this is displayed
selectElement.firstChild.appendChild(menuItemNode);
@ -68,8 +68,8 @@ function onLoad()
function setDetails()
{
var index = parseInt(document.getElementById("nicknames").value);
var details = dialogParams.GetString(index+itemCount+3);
let index = parseInt(document.getElementById("nicknames").value);
let details = dialogParams.GetString(index + itemCount + 3);
document.getElementById("details").value = details;
}

View File

@ -62,9 +62,8 @@ function setWindowName()
setText("confirm",confirm);
var box=document.getElementById("certlist");
for(var x=0;x<numberOfCerts;x++)
{
let box = document.getElementById("certlist");
for (let x = 0; x < numberOfCerts; x++) {
var listItem = document.createElement("richlistitem");
var label = document.createElement("label");
label.setAttribute("value", gParams.GetString(x + 1));

View File

@ -148,11 +148,11 @@ function AddModule(module, slots)
row.appendChild(cell);
item.appendChild(row);
var parent = document.createElement("treechildren");
for (var i = 0; i<slots.length; i++) {
for (let slot of slots) {
var child_item = document.createElement("treeitem");
var child_row = document.createElement("treerow");
var child_cell = document.createElement("treecell");
child_cell.setAttribute("label", slots[i]);
child_cell.setAttribute("label", slot);
child_row.appendChild(child_cell);
child_item.appendChild(child_row);
child_item.setAttribute("pk11kind", "slot");

View File

@ -10,7 +10,7 @@ const nsIPKCS11Slot = Components.interfaces.nsIPKCS11Slot;
const nsIPK11Token = Components.interfaces.nsIPK11Token;
var params;
var tokenName="";
var tokenName = "";
var pw1;
function doPrompt(msg)
@ -42,7 +42,7 @@ function onLoad()
var sectokdb = Components.classes[nsPK11TokenDB].getService(nsIPK11TokenDB);
var tokenList = sectokdb.listTokens();
var enumElement;
var i=0;
let i = 0;
var menu = document.getElementById("tokenMenu");
try {
for (; !tokenList.isDone(); tokenList.next()) {
@ -233,7 +233,7 @@ function setPasswordStrength()
}
let numnumeric = pw.replace(/[0-9]/g, "");
let numeric= pw.length - numnumeric.length;
let numeric = pw.length - numnumeric.length;
if (numeric > 3) {
numeric = 3;
}
@ -269,8 +269,8 @@ function setPasswordStrength()
function checkPasswords()
{
var pw1=document.getElementById('pw1').value;
var pw2=document.getElementById('pw2').value;
let pw1 = document.getElementById("pw1").value;
let pw2 = document.getElementById("pw2").value;
var oldpwbox = document.getElementById("oldpw");
if (oldpwbox) {

View File

@ -25,13 +25,11 @@ function doPrompt(msg)
function AddCertChain(node, chain, idPrefix)
{
var idfier = idPrefix+"chain_";
var child = document.getElementById(node);
var numCerts = chain.length;
var currCert;
var displayVal;
var addTwistie;
for (var i=numCerts-1; i>=0; i--) {
for (let i = chain.length - 1; i >= 0; i--) {
currCert = chain.queryElementAt(i, nsIX509Cert);
if (currCert.commonName) {
displayVal = currCert.commonName;
@ -130,7 +128,7 @@ function displaySelected() {
var value = asn1Tree.getDisplayData(items.currentIndex);
certDumpVal.value = value;
} else {
certDumpVal.value ="";
certDumpVal.value = "";
}
}
@ -213,11 +211,11 @@ function DisplayVerificationData(cert, result)
} else { /* if (verifystate == cert.NOT_VERIFIED_UNKNOWN || == USAGE_NOT_ALLOWED) */
verifystr = bundle.getString('certNotVerified_Unknown');
}
var verified=document.getElementById('verified');
let verified = document.getElementById("verified");
verified.textContent = verifystr;
if (count > 0) {
var verifyInfoBox = document.getElementById('verify_info_box');
for (var i=0; i<count; i++) {
for (let i = 0; i < count; i++) {
AddUsage(usageList[i],verifyInfoBox);
}
}

View File

@ -149,10 +149,11 @@ function ok(a, message)
function is(a, b, message)
{
if (a != b)
postMsg("FAILURE: " + message + ", expected "+b+" got "+a);
else
postMsg(message + ", expected "+b+" got "+a);
if (a != b) {
postMsg(`FAILURE: ${message}, expected ${b} got ${a}`);
} else {
postMsg(`${message}, expected ${b} got ${a}`);
}
}
function todo(a, message)

View File

@ -15,7 +15,8 @@
isSecurityState("secure");
window.setTimeout(function () {
var newElement = document.createElement("script");
newElement.src= "http://example.org/tests/security/manager/ssl/tests/mochitest/mixedcontent/bug329869.js";
newElement.src = "http://example.org/tests/security/manager/ssl/tests/" +
"mochitest/mixedcontent/bug329869.js";
document.body.appendChild(newElement);
}, 0);
}

View File

@ -182,8 +182,6 @@ function checkCertErrorGeneric(certdb, cert, expectedError, usage,
}
function checkEVStatus(certDB, cert, usage, isEVExpected) {
do_print(`cert o=${cert.organization}`);
do_print(`cert issuer o=${cert.issuerOrganization}`);
let hasEVPolicy = {};
checkCertErrorGeneric(certDB, cert, PRErrorCodeSuccess, usage, hasEVPolicy);
Assert.equal(hasEVPolicy.value, isEVExpected,
@ -498,7 +496,7 @@ function generateOCSPResponses(ocspRespArray, nssDBlocation)
argArray.push(ocspRespArray[i][1]); // nick;
argArray.push(ocspRespArray[i][2]); // extranickname
argArray.push(filename);
do_print("arg_array ="+argArray);
do_print("argArray = " + argArray);
let process = Cc["@mozilla.org/process/util;1"]
.createInstance(Ci.nsIProcess);

View File

@ -128,9 +128,9 @@ var initialBlocklist = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
// also in the blocklist
"<certItem issuerName='YW5vdGhlciBpbWFnaW5hcnkgaXNzdWVy'>" +
"<serialNumber>c2VyaWFsMi4=</serialNumber>" +
"<serialNumber>YW5vdGhlciBzZXJpYWwu</serialNumber>" +
"<serialNumber>YW5vdGhlciBzZXJpYWwu</serialNumber></certItem>" +
// This item revokes same-issuer-ee.pem by subject and pubKeyHash.
"</certItem><certItem subject='MCIxIDAeBgNVBAMMF0Fub3RoZXIgVGVzdCBFbmQtZW50aXR5'"+
"<certItem subject='MCIxIDAeBgNVBAMMF0Fub3RoZXIgVGVzdCBFbmQtZW50aXR5'" +
" pubKeyHash='VCIlmPM9NkgFQtrs4Oa5TeFcDu6MWRTKSNdePEhOgD8='>" +
"</certItem></certItems></blocklist>";
@ -250,8 +250,8 @@ function run_test() {
.getService(Ci.nsICertBlocklist);
let expected = "# Auto generated contents. Do not edit.\n" +
"MCIxIDAeBgNVBAMMF0Fub3RoZXIgVGVzdCBFbmQtZW50aXR5\n"+
"\tVCIlmPM9NkgFQtrs4Oa5TeFcDu6MWRTKSNdePEhOgD8=\n"+
"MCIxIDAeBgNVBAMMF0Fub3RoZXIgVGVzdCBFbmQtZW50aXR5\n" +
"\tVCIlmPM9NkgFQtrs4Oa5TeFcDu6MWRTKSNdePEhOgD8=\n" +
"MBIxEDAOBgNVBAMMB1Rlc3QgQ0E=\n" +
" BVio/iQ21GCi2iUven8oJ/gae74=\n" +
"MBgxFjAUBgNVBAMMDU90aGVyIHRlc3QgQ0E=\n" +

View File

@ -10,7 +10,7 @@
var gFetchCount = 0;
var gGoodOCSPResponse = null;
var gResponsePattern = [];
var gMessage= "";
var gMessage = "";
function respondWithGoodOCSP(request, response) {
do_print("returning 200 OK");

View File

@ -45,7 +45,7 @@ function checkPassValidPin(pinValue, settingPin) {
gSSService.removeState(Ci.nsISiteSecurityService.HEADER_HPKP, uri, 0);
} else {
// add a known valid pin!
let validPinValue ="max-age=5000;" + VALID_PIN1 + BACKUP_PIN1;
let validPinValue = "max-age=5000;" + VALID_PIN1 + BACKUP_PIN1;
gSSService.processHeader(Ci.nsISiteSecurityService.HEADER_HPKP, uri,
validPinValue, sslStatus, 0);
}
@ -79,9 +79,9 @@ const NON_ISSUED_KEY_HASH1 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
const NON_ISSUED_KEY_HASH2 = "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ=";
const PINNING_ROOT_KEY_HASH = "VCIlmPM9NkgFQtrs4Oa5TeFcDu6MWRTKSNdePEhOgD8=";
const MAX_AGE_ZERO = "max-age=0;"
const VALID_PIN1 = "pin-sha256=\""+ PINNING_ROOT_KEY_HASH + "\";";
const BACKUP_PIN1 = "pin-sha256=\""+ NON_ISSUED_KEY_HASH1 + "\";";
const BACKUP_PIN2 = "pin-sha256=\""+ NON_ISSUED_KEY_HASH2 + "\";";
const VALID_PIN1 = `pin-sha256="${PINNING_ROOT_KEY_HASH}";`;
const BACKUP_PIN1 = `pin-sha256="${NON_ISSUED_KEY_HASH1}";`;
const BACKUP_PIN2 = `pin-sha256="${NON_ISSUED_KEY_HASH2}";`;
const BROKEN_PIN1 = "pin-sha256=\"jdjsjsjs\";";
const GOOD_MAX_AGE = "max-age=69403;";
const INCLUDE_SUBDOMAINS = "includeSubdomains;";

View File

@ -443,7 +443,7 @@ function genExpirationTime() {
let expirationMillis = nowMillis + (PINNING_MINIMUM_REQUIRED_MAX_AGE * 1000);
let expirationMicros = expirationMillis * 1000;
return "static const PRTime kPreloadPKPinsExpirationTime = INT64_C(" +
expirationMicros +");\n";
expirationMicros + ");\n";
}
function writeFullPinset(certNameToSKD, certSKDToName, pinset) {

View File

@ -130,7 +130,7 @@ function writeRootHashes(fos) {
let fpBytes = atob(fp.sha256Fingerprint);
writeString(fos, " {\n");
writeString(fos, " /* "+fp.label+" */\n");
writeString(fos, " /* " + fp.label + " */\n");
writeString(fos, " { " + hexSlice(fpBytes, 0, 16) + ",\n");
writeString(fos, " " + hexSlice(fpBytes, 16, 32) + " },\n");
writeString(fos, " " + fp.binNumber + " /* Bin Number */\n");