Bug 1372427 - enforce balanced-listeners. r=mattn
MozReview-Commit-ID: KpPZA2godKg
--- a/toolkit/components/satchel/.eslintrc.js
+++ b/toolkit/components/satchel/.eslintrc.js
@@ -1,14 +1,15 @@
"use strict";
module.exports = {
rules: {
"mozilla/no-cpows-in-tests": "error",
"mozilla/var-only-at-top-level": "error",
+ "mozilla/balanced-listeners": "error",
curly: ["error", "all"],
indent: ["error", 2, {
SwitchCase: 1,
CallExpression: {
arguments: "first",
},
FunctionExpression: {
--- a/toolkit/components/satchel/test/test_popup_enter_event.html
+++ b/toolkit/components/satchel/test/test_popup_enter_event.html
@@ -54,19 +54,23 @@ function handleEnter(evt) {
function popupShownListener(evt) {
doKey("down");
doKey("return"); // select the first entry in the popup
doKey("return"); // try to submit the form with the filled value
}
function runTest() {
input.addEventListener("keypress", handleEnter, true);
- form.addEventListener("submit", evt => {
+ form.addEventListener("submit", function submitCallback(evt) {
is(input.value, expectedValue, "Check input value in the submit handler");
evt.preventDefault();
+
+ input.removeEventListener("keypress", handleEnter, true);
+ form.removeEventListener("submit", submitCallback);
+
SimpleTest.finish();
});
// Focus the input before adjusting.value so that the caret goes to the end
// (since OS X doesn't show the dropdown otherwise).
input.focus();
input.value = "value";
input.focus();