Bug 1425244 - Enable ESLint rule no-lonely-if for accessible/tests/mochitest/. r?surkov
MozReview-Commit-ID: DILOcLjsaoF
--- a/accessible/tests/mochitest/.eslintrc.js
+++ b/accessible/tests/mochitest/.eslintrc.js
@@ -6,17 +6,16 @@ module.exports = {
],
"rules": {
"mozilla/no-cpows-in-tests": "error",
"mozilla/reject-importGlobalProperties": "error",
// XXX These are rules that are enabled in the recommended configuration, but
// disabled here due to failures when initially implemented. They should be
// removed (and hence enabled) at some stage.
- "no-lonely-if": "off",
"no-nested-ternary": "off",
"no-new-object": "off",
"no-redeclare": "off",
"no-shadow": "off",
"no-undef": "off",
"space-unary-ops": "off",
}
};
--- a/accessible/tests/mochitest/events.js
+++ b/accessible/tests/mochitest/events.js
@@ -331,22 +331,20 @@ function eventQueue(aEventType) {
var checker = eventSeq[idx];
var typeStr = eventQueue.getEventTypeAsString(checker);
var msg = "Test with ID = '" + this.getEventID(checker) +
"' succeed. ";
if (checker.unexpected) {
ok(true, msg + `There's no unexpected '${typeStr}' event.`);
+ } else if (checker.todo) {
+ todo(false, `Todo event '${typeStr}' was caught`);
} else {
- if (checker.todo) {
- todo(false, `Todo event '${typeStr}' was caught`);
- } else {
- ok(true, `${msg} Event '${typeStr}' was handled.`);
- }
+ ok(true, `${msg} Event '${typeStr}' was handled.`);
}
}
}
}
}
// We don't have completely matched scenario. Report each failure/success
// for every scenario.
@@ -1996,16 +1994,17 @@ var gA11yEventObserver =
function listenA11yEvents(aStartToListen) {
if (aStartToListen) {
// Add observer when adding the first applicant only.
if (!(gA11yEventApplicantsCount++))
Services.obs.addObserver(gA11yEventObserver, "accessible-event");
} else {
// Remove observer when there are no more applicants only.
// '< 0' case should not happen, but just in case: removeObserver() will throw.
+ // eslint-disable-next-line no-lonely-if
if (--gA11yEventApplicantsCount <= 0)
Services.obs.removeObserver(gA11yEventObserver, "accessible-event");
}
}
function addA11yEventListener(aEventType, aEventHandler) {
if (!(aEventType in gA11yEventListeners))
gA11yEventListeners[aEventType] = [];
--- a/accessible/tests/mochitest/events/test_focus_general.html
+++ b/accessible/tests/mochitest/events/test_focus_general.html
@@ -101,20 +101,19 @@
gQueue.push(new toggleTopMenu(editableDoc, new topMenuChecker()));
gQueue.push(new toggleTopMenu(editableDoc, new focusChecker(editableDoc)));
}
gQueue.push(new synthContextMenu(editableDoc, new contextMenuChecker()));
gQueue.push(new synthDownKey(editableDoc, new focusContextMenuItemChecker()));
gQueue.push(new synthEscapeKey(editableDoc, new focusChecker(editableDoc)));
if (SEAMONKEY) {
todo(false, "shift tab from editable document fails on (Windows) SeaMonkey! (Bug 718235)");
+ } else if (LINUX || MAC) {
+ todo(false, "shift tab from editable document fails on linux and Mac, bug 746519!");
} else {
- if (LINUX || MAC)
- todo(false, "shift tab from editable document fails on linux and Mac, bug 746519!");
- else
gQueue.push(new synthShiftTab("link", new focusChecker("link")));
} // ! SEAMONKEY
gQueue.push(new synthFocus("a", new imageMapChecker("a")));
gQueue.push(new synthFocus("b", new imageMapChecker("b")));
gQueue.invoke(); // Will call SimpleTest.finish();
}
--- a/accessible/tests/mochitest/jsat/jsatcommon.js
+++ b/accessible/tests/mochitest/jsat/jsatcommon.js
@@ -495,23 +495,21 @@ ExpectedMessage.prototype.lazyCompare =
var expected = aExpected[attr];
var received = aReceived[attr];
if (typeof expected === "object") {
var [childMatches, childDelta] = this.lazyCompare(received, expected);
if (!childMatches) {
delta.push(attr + " [ " + childDelta + " ]");
matches = false;
}
- } else {
- if (received !== expected) {
- delta.push(
- attr + " [ expected " + JSON.stringify(expected) +
- " got " + JSON.stringify(received) + " ]");
- matches = false;
- }
+ } else if (received !== expected) {
+ delta.push(
+ attr + " [ expected " + JSON.stringify(expected) +
+ " got " + JSON.stringify(received) + " ]");
+ matches = false;
}
}
var msg = delta.length ? delta.join(" ") : "Structures lazily match";
return [matches, msg + " -- " + aInfo];
};
ExpectedMessage.prototype.is = function(aReceived, aInfo) {