mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 14:25:52 +00:00
Bug 1244245 - Enable eslint "curly" rule for PSM. r=keeler
Also includes minor cleanup. MozReview-Commit-ID: CHgbTIa3s2O --HG-- extra : transplant_source : %FD%ACi%DE%3E%28%0D%D2_%5Dc%1Dk%E6%E8%EDw%D5%FA%93
This commit is contained in:
parent
70bc936cba
commit
eb91d4f287
@ -12,6 +12,9 @@
|
||||
// Functions must always return something or nothing
|
||||
"consistent-return": 2,
|
||||
|
||||
// Require braces around blocks that start a new line
|
||||
"curly": [2, "multi-line"],
|
||||
|
||||
// Always require a trailing EOL
|
||||
"eol-last": 2,
|
||||
|
||||
|
@ -294,8 +294,10 @@ function backupCerts()
|
||||
{
|
||||
getSelectedCerts();
|
||||
var numcerts = selected_certs.length;
|
||||
if (!numcerts)
|
||||
if (numcerts == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var bundle = document.getElementById("pippki_bundle");
|
||||
var fp = Components.classes[nsFilePicker].createInstance(nsIFilePicker);
|
||||
fp.init(window,
|
||||
@ -396,8 +398,9 @@ function deleteCerts()
|
||||
{
|
||||
getSelectedTreeItems();
|
||||
var numcerts = selected_tree_items.length;
|
||||
if (!numcerts)
|
||||
if (numcerts == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var params = Components.classes[nsDialogParamBlock].createInstance(nsIDialogParamBlock);
|
||||
|
||||
|
@ -96,12 +96,10 @@ function RefreshDeviceList()
|
||||
// prefer lookup by token name. However, the token may not be
|
||||
// present, so maybe slot names should be listed, while token names
|
||||
// are "remembered" for lookup?
|
||||
if (slot != null) {
|
||||
if (slot.tokenName)
|
||||
slotnames[slotnames.length] = slot.tokenName;
|
||||
else
|
||||
slotnames[slotnames.length] = slot.name;
|
||||
}
|
||||
if (slot != null) {
|
||||
slotnames[slotnames.length] = slot.tokenName ? slot.tokenName
|
||||
: slot.name;
|
||||
}
|
||||
try {
|
||||
slots.next();
|
||||
} catch (e) { slots_done = true; }
|
||||
@ -199,8 +197,9 @@ function getSelectedItem()
|
||||
|
||||
function enableButtons()
|
||||
{
|
||||
if (skip_enable_buttons)
|
||||
if (skip_enable_buttons) {
|
||||
return;
|
||||
}
|
||||
|
||||
var login_toggle = "true";
|
||||
var logout_toggle = "true";
|
||||
@ -244,9 +243,10 @@ function enableButtons()
|
||||
// clear the display of information for the slot
|
||||
function ClearInfoList()
|
||||
{
|
||||
var info_list = document.getElementById("info_list");
|
||||
while (info_list.firstChild)
|
||||
info_list.removeChild(info_list.firstChild);
|
||||
let infoList = document.getElementById("info_list");
|
||||
while (infoList.hasChildNodes()) {
|
||||
infoList.removeChild(infoList.firstChild);
|
||||
}
|
||||
}
|
||||
|
||||
function ClearDeviceList()
|
||||
@ -469,12 +469,12 @@ function doLoadDevice()
|
||||
var path_box = document.getElementById("device_path");
|
||||
try {
|
||||
getPKCS11().addModule(name_box.value, path_box.value, 0,0);
|
||||
}
|
||||
catch (e) {
|
||||
if (e.result == Components.results.NS_ERROR_ILLEGAL_VALUE)
|
||||
} catch (e) {
|
||||
if (e.result == Components.results.NS_ERROR_ILLEGAL_VALUE) {
|
||||
doPrompt(getNSSString("AddModuleDup"));
|
||||
else
|
||||
} else {
|
||||
doPrompt(getNSSString("AddModuleFailure"));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -32,22 +32,17 @@ function viewCert()
|
||||
|
||||
function doOK()
|
||||
{
|
||||
var checkSSL = document.getElementById("trustSSL");
|
||||
var checkEmail = document.getElementById("trustEmail");
|
||||
var checkObjSign = document.getElementById("trustObjSign");
|
||||
if (checkSSL.checked)
|
||||
params.SetInt(2,1);
|
||||
else
|
||||
params.SetInt(2,0);
|
||||
if (checkEmail.checked)
|
||||
params.SetInt(3,1);
|
||||
else
|
||||
params.SetInt(3,0);
|
||||
if (checkObjSign.checked)
|
||||
params.SetInt(4,1);
|
||||
else
|
||||
params.SetInt(4,0);
|
||||
params.SetInt(1,1);
|
||||
let checkSSL = document.getElementById("trustSSL");
|
||||
let checkEmail = document.getElementById("trustEmail");
|
||||
let checkObjSign = document.getElementById("trustObjSign");
|
||||
|
||||
// Signal which trust bits the user wanted to enable.
|
||||
params.SetInt(2, checkSSL.checked ? 1 : 0);
|
||||
params.SetInt(3, checkEmail.checked ? 1 : 0);
|
||||
params.SetInt(4, checkObjSign.checked ? 1 : 0);
|
||||
|
||||
// Signal that the user accepted.
|
||||
params.SetInt(1, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -24,14 +24,16 @@ badCertListener.prototype = {
|
||||
QueryInterface: function(aIID) {
|
||||
if (aIID.equals(Components.interfaces.nsIBadCertListener2) ||
|
||||
aIID.equals(Components.interfaces.nsIInterfaceRequestor) ||
|
||||
aIID.equals(Components.interfaces.nsISupports))
|
||||
aIID.equals(Components.interfaces.nsISupports)) {
|
||||
return this;
|
||||
}
|
||||
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
},
|
||||
handle_test_result: function () {
|
||||
if (gSSLStatus)
|
||||
if (gSSLStatus) {
|
||||
gCert = gSSLStatus.QueryInterface(Components.interfaces.nsISSLStatus).serverCert;
|
||||
}
|
||||
},
|
||||
notifyCertProblem: function MSR_notifyCertProblem(socketInfo, sslStatus, targetHost) {
|
||||
gBroken = true;
|
||||
@ -314,8 +316,9 @@ function viewCertButtonClick() {
|
||||
* Handle user request to add an exception for the specified cert
|
||||
*/
|
||||
function addException() {
|
||||
if(!gCert || !gSSLStatus)
|
||||
if (!gCert || !gSSLStatus) {
|
||||
return;
|
||||
}
|
||||
|
||||
var overrideService = Components.classes["@mozilla.org/security/certoverride;1"]
|
||||
.getService(Components.interfaces.nsICertOverrideService);
|
||||
@ -336,8 +339,9 @@ function addException() {
|
||||
|
||||
var permanentCheckbox = document.getElementById("permanent");
|
||||
var shouldStorePermanently = permanentCheckbox.checked && !inPrivateBrowsingMode();
|
||||
if(!permanentCheckbox.checked)
|
||||
gSecHistogram.add(gNsISecTel.WARNING_BAD_CERT_TOP_DONT_REMEMBER_EXCEPTION);
|
||||
if (!permanentCheckbox.checked) {
|
||||
gSecHistogram.add(gNsISecTel.WARNING_BAD_CERT_TOP_DONT_REMEMBER_EXCEPTION);
|
||||
}
|
||||
|
||||
gSecHistogram.add(confirmBucketId);
|
||||
var uri = getURI();
|
||||
|
@ -199,9 +199,10 @@ function setPassword()
|
||||
success = true;
|
||||
}
|
||||
|
||||
if (success && params)
|
||||
if (success && params) {
|
||||
// Return value 1 means "successfully executed ok"
|
||||
params.SetInt(1, 1);
|
||||
}
|
||||
|
||||
// Terminate dialog
|
||||
return success;
|
||||
|
@ -10,20 +10,23 @@
|
||||
*/
|
||||
|
||||
function setText(id, value) {
|
||||
var element = document.getElementById(id);
|
||||
if (!element) return;
|
||||
if (element.hasChildNodes())
|
||||
element.removeChild(element.firstChild);
|
||||
var textNode = document.createTextNode(value);
|
||||
element.appendChild(textNode);
|
||||
let element = document.getElementById(id);
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
if (element.hasChildNodes()) {
|
||||
element.removeChild(element.firstChild);
|
||||
}
|
||||
element.appendChild(document.createTextNode(value));
|
||||
}
|
||||
|
||||
const nsICertificateDialogs = Components.interfaces.nsICertificateDialogs;
|
||||
const nsCertificateDialogs = "@mozilla.org/nsCertificateDialogs;1"
|
||||
|
||||
function viewCertHelper(parent, cert) {
|
||||
if (!cert)
|
||||
if (!cert) {
|
||||
return;
|
||||
}
|
||||
|
||||
var cd = Components.classes[nsCertificateDialogs].getService(nsICertificateDialogs);
|
||||
cd.viewCert(parent, cert);
|
||||
@ -108,8 +111,9 @@ function exportToFile(parent, cert)
|
||||
case 1:
|
||||
content = getPEMString(cert);
|
||||
var chain = cert.getChain();
|
||||
for (var i = 1; i < chain.length; i++)
|
||||
for (let i = 1; i < chain.length; i++) {
|
||||
content += getPEMString(chain.queryElementAt(i, Components.interfaces.nsIX509Cert));
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
content = getDERString(cert);
|
||||
@ -156,8 +160,9 @@ function exportToFile(parent, cert)
|
||||
}
|
||||
}
|
||||
if (written != content.length) {
|
||||
if (!msg.length)
|
||||
if (msg.length == 0) {
|
||||
msg = bundle.getString("writeFileUnknownError");
|
||||
}
|
||||
alertPromptService(bundle.getString("writeFileFailure"),
|
||||
bundle.getFormattedString("writeFileFailed",
|
||||
[fp.file.path, msg]));
|
||||
|
@ -111,8 +111,9 @@ function addTreeItemToTreeChild(treeChild,label,value,addTwistie)
|
||||
var treeRow = document.createElement("treerow");
|
||||
var treeCell = document.createElement("treecell");
|
||||
treeCell.setAttribute("label",label);
|
||||
if (value)
|
||||
if (value) {
|
||||
treeCell.setAttribute("display",value);
|
||||
}
|
||||
treeRow.appendChild(treeCell);
|
||||
treeElem1.appendChild(treeRow);
|
||||
treeChild.appendChild(treeElem1);
|
||||
@ -157,8 +158,9 @@ function listener() {
|
||||
listener.prototype.QueryInterface =
|
||||
function(iid) {
|
||||
if (iid.equals(Components.interfaces.nsISupports) ||
|
||||
iid.equals(Components.interfaces.nsICertVerificationListener))
|
||||
return this;
|
||||
iid.equals(Components.interfaces.nsICertVerificationListener)) {
|
||||
return this;
|
||||
}
|
||||
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
@ -172,11 +174,13 @@ function DisplayVerificationData(cert, result)
|
||||
{
|
||||
document.getElementById("verify_pending").setAttribute("hidden", "true");
|
||||
|
||||
if (!result || !cert)
|
||||
if (!result || !cert) {
|
||||
return; // no results could be produced
|
||||
}
|
||||
|
||||
if (!(cert instanceof Components.interfaces.nsIX509Cert))
|
||||
if (!(cert instanceof Components.interfaces.nsIX509Cert)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Verification and usage
|
||||
var verifystr = "";
|
||||
@ -184,8 +188,9 @@ function DisplayVerificationData(cert, result)
|
||||
var o2 = {};
|
||||
var o3 = {};
|
||||
|
||||
if (!(result instanceof Components.interfaces.nsICertVerificationResult))
|
||||
if (!(result instanceof Components.interfaces.nsICertVerificationResult)) {
|
||||
return;
|
||||
}
|
||||
|
||||
result.getUsagesArrayResult(o1, o2, o3);
|
||||
|
||||
|
@ -30,35 +30,25 @@ var hasMixedActiveContent = false;
|
||||
// Internal variables
|
||||
var _windowCount = 0;
|
||||
|
||||
window.onload = function onLoad()
|
||||
{
|
||||
if (location.search == "?runtest")
|
||||
{
|
||||
try
|
||||
{
|
||||
if (history.length == 1)
|
||||
window.onload = function onLoad() {
|
||||
if (location.search == "?runtest") {
|
||||
try {
|
||||
if (history.length == 1) {
|
||||
runTest();
|
||||
else
|
||||
} else {
|
||||
afterNavigationTest();
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
}
|
||||
} catch (ex) {
|
||||
ok(false, "Exception thrown during test: " + ex);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
window.addEventListener("message", onMessageReceived, false);
|
||||
|
||||
var secureTestLocation;
|
||||
if (loadAsInsecure)
|
||||
secureTestLocation = "http://example.com";
|
||||
else
|
||||
secureTestLocation = "https://example.com";
|
||||
let secureTestLocation = loadAsInsecure ? "http://example.com"
|
||||
: "https://example.com";
|
||||
secureTestLocation += location.pathname
|
||||
if (testPage != "")
|
||||
{
|
||||
if (testPage != "") {
|
||||
array = secureTestLocation.split("/");
|
||||
array.pop();
|
||||
array.push(testPage);
|
||||
@ -66,20 +56,16 @@ window.onload = function onLoad()
|
||||
}
|
||||
secureTestLocation += "?runtest";
|
||||
|
||||
if (hasMixedActiveContent)
|
||||
{
|
||||
if (hasMixedActiveContent) {
|
||||
SpecialPowers.pushPrefEnv(
|
||||
{"set": [["security.mixed_content.block_active_content", false]]},
|
||||
null);
|
||||
}
|
||||
if (openTwoWindows)
|
||||
{
|
||||
if (openTwoWindows) {
|
||||
_windowCount = 2;
|
||||
window.open(secureTestLocation, "_new1", "");
|
||||
window.open(secureTestLocation, "_new2", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
_windowCount = 1;
|
||||
window.open(secureTestLocation);
|
||||
}
|
||||
@ -88,14 +74,13 @@ window.onload = function onLoad()
|
||||
|
||||
function onMessageReceived(event)
|
||||
{
|
||||
switch (event.data)
|
||||
{
|
||||
switch (event.data) {
|
||||
// Indication of all test parts finish (from any of the frames)
|
||||
case "done":
|
||||
if (--_windowCount == 0)
|
||||
{
|
||||
if (testCleanUp)
|
||||
if (--_windowCount == 0) {
|
||||
if (testCleanUp) {
|
||||
testCleanUp();
|
||||
}
|
||||
if (hasMixedActiveContent) {
|
||||
SpecialPowers.popPrefEnv(null);
|
||||
}
|
||||
@ -104,14 +89,9 @@ function onMessageReceived(event)
|
||||
}
|
||||
break;
|
||||
|
||||
// Any other message indicates error or succes message of a test
|
||||
// Any other message is an error or success message of a test.
|
||||
default:
|
||||
var failureRegExp = new RegExp("^FAILURE");
|
||||
var todoRegExp = new RegExp("^TODO");
|
||||
if (event.data.match(todoRegExp))
|
||||
SimpleTest.todo(false, event.data);
|
||||
else
|
||||
SimpleTest.ok(!event.data.match(failureRegExp), event.data);
|
||||
SimpleTest.ok(!event.data.match(/^FAILURE/), event.data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -141,10 +121,11 @@ function finish()
|
||||
|
||||
function ok(a, message)
|
||||
{
|
||||
if (!a)
|
||||
if (!a) {
|
||||
postMsg("FAILURE: " + message);
|
||||
else
|
||||
} else {
|
||||
postMsg(message);
|
||||
}
|
||||
}
|
||||
|
||||
function is(a, b, message)
|
||||
@ -156,18 +137,11 @@ function is(a, b, message)
|
||||
}
|
||||
}
|
||||
|
||||
function todo(a, message)
|
||||
{
|
||||
if (a)
|
||||
postMsg("FAILURE: TODO works? " + message);
|
||||
else
|
||||
postMsg("TODO: " + message);
|
||||
}
|
||||
|
||||
function isSecurityState(expectedState, message, test)
|
||||
{
|
||||
if (!test)
|
||||
if (!test) {
|
||||
test = ok;
|
||||
}
|
||||
|
||||
// Quit nasty but working :)
|
||||
var ui = SpecialPowers.wrap(window)
|
||||
@ -184,19 +158,19 @@ function isSecurityState(expectedState, message, test)
|
||||
(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_IDENTITY_EV_TOPLEVEL);
|
||||
|
||||
var gotState;
|
||||
if (isInsecure)
|
||||
if (isInsecure) {
|
||||
gotState = "insecure";
|
||||
else if (isBroken)
|
||||
} else if (isBroken) {
|
||||
gotState = "broken";
|
||||
else if (isEV)
|
||||
} else if (isEV) {
|
||||
gotState = "EV";
|
||||
else
|
||||
} else {
|
||||
gotState = "secure";
|
||||
}
|
||||
|
||||
test(gotState == expectedState, (message || "") + ", " + "expected " + expectedState + " got " + gotState);
|
||||
|
||||
switch (expectedState)
|
||||
{
|
||||
switch (expectedState) {
|
||||
case "insecure":
|
||||
test(isInsecure && !isBroken && !isEV, "for 'insecure' excpected flags [1,0,0], " + (message || ""));
|
||||
break;
|
||||
|
@ -80,9 +80,11 @@
|
||||
|
||||
var prefKeys = ["dir", "useDownloadDir", "folderList",
|
||||
"manager.closeWhenDone", "manager.showWhenStarting"];
|
||||
for (var i = 0; i < prefKeys.length; i++)
|
||||
if (prefs.prefHasUserValue(prefKeys[i]))
|
||||
prefs.clearUserPref(prefKeys[i]);
|
||||
for (let prefKey of prefKeys) {
|
||||
if (prefs.prefHasUserValue(prefKey)) {
|
||||
prefs.clearUserPref(prefKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
@ -43,8 +43,9 @@
|
||||
function endRound(round) {
|
||||
// remove all the iframes in the document
|
||||
document.body.removeChild(document.getElementById('ifr_bootstrap'));
|
||||
for (var test in testframes)
|
||||
for (let test in testframes) {
|
||||
document.body.removeChild(document.getElementById('ifr_' + test));
|
||||
}
|
||||
|
||||
// clean up the STS state
|
||||
SpecialPowers.cleanUpSTSData("http://example.com");
|
||||
@ -93,10 +94,11 @@
|
||||
roundsLeft--;
|
||||
|
||||
// defer this so it doesn't muck with the stack too much.
|
||||
if (roundsLeft == 1)
|
||||
if (roundsLeft == 1) {
|
||||
setTimeout(function () {
|
||||
startRound("subdom");
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (roundsLeft < 1) {
|
||||
|
@ -111,8 +111,9 @@
|
||||
} else {
|
||||
onMessageReceived(win, isPrivate, "INSECURE " + testName);
|
||||
}
|
||||
if (aCallback)
|
||||
if (aCallback) {
|
||||
aCallback();
|
||||
}
|
||||
});
|
||||
win.content.document.body.appendChild(frame);
|
||||
}
|
||||
@ -150,13 +151,15 @@
|
||||
// remove all the iframes in the document
|
||||
win.content.document.body.removeChild(
|
||||
win.content.document.getElementById('ifr_bootstrap'));
|
||||
for (var test in testframes)
|
||||
for (let test in testframes) {
|
||||
win.content.document.body.removeChild(
|
||||
win.content.document.getElementById('ifr_' + test));
|
||||
}
|
||||
currentround = "";
|
||||
|
||||
if (!isPrivate)
|
||||
if (!isPrivate) {
|
||||
clean_up_sts_state(isPrivate);
|
||||
}
|
||||
// Close test window.
|
||||
win.close();
|
||||
// And advance to the next test.
|
||||
|
@ -57,8 +57,9 @@ function tamper(inFilePath, outFilePath, modifications, newEntries) {
|
||||
outEntryInput,
|
||||
false);
|
||||
} finally {
|
||||
if (entryInput != outEntryInput)
|
||||
if (entryInput != outEntryInput) {
|
||||
outEntryInput.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
@ -100,8 +101,9 @@ function tamper(inFilePath, outFilePath, modifications, newEntries) {
|
||||
function removeEntry(entry, entryInput) { return [null, null]; }
|
||||
|
||||
function truncateEntry(entry, entryInput) {
|
||||
if (entryInput.available() == 0)
|
||||
if (entryInput.available() == 0) {
|
||||
throw "Truncating already-zero length entry will result in identical entry.";
|
||||
}
|
||||
|
||||
var content = Cc["@mozilla.org/io/string-input-stream;1"]
|
||||
.createInstance(Ci.nsIStringInputStream);
|
||||
|
@ -10,8 +10,9 @@ var gSSService = Cc["@mozilla.org/ssservice;1"]
|
||||
function Observer() {}
|
||||
Observer.prototype = {
|
||||
observe: function(subject, topic, data) {
|
||||
if (topic == "last-pb-context-exited")
|
||||
if (topic == "last-pb-context-exited") {
|
||||
run_next_test();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -240,12 +240,13 @@ gTrustAnchors.roots.sort(function(a, b) {
|
||||
let aBin = atob(a.sha256Fingerprint);
|
||||
let bBin = atob(b.sha256Fingerprint)
|
||||
|
||||
if (aBin < bBin)
|
||||
return -1;
|
||||
else if (aBin > bBin)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
if (aBin < bBin) {
|
||||
return -1;
|
||||
}
|
||||
if (aBin > bBin) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
// Write the output file.
|
||||
|
@ -304,10 +304,11 @@ function getHSTSStatuses(inHosts, outStatuses) {
|
||||
waitForAResponse(tmpOutput);
|
||||
var response = tmpOutput.shift();
|
||||
dump("request to '" + response.name + "' finished\n");
|
||||
if (shouldRetry(response))
|
||||
if (shouldRetry(response)) {
|
||||
inHosts.push(response);
|
||||
else
|
||||
} else {
|
||||
outStatuses.push(response);
|
||||
}
|
||||
|
||||
if (inHosts.length > 0) {
|
||||
var host = inHosts.shift();
|
||||
|
Loading…
Reference in New Issue
Block a user