Bug 1372427 - enforce balanced-listeners. r=mattn draft
authorJonathan Guillotte-Blouin <jguillotteblouin@mozilla.com>
Fri, 16 Jun 2017 15:12:32 -0700
changeset 597803 beca1e626ba5e51cffaa385a3f38acea3011f05d
parent 597802 4d524379de87cf943ec035ae11506a9510e66a38
child 597806 25c3daa01b8f5192bb2793d0c1982d7d20f4805b
push id65027
push userbmo:jguillotteblouin@mozilla.com
push dateTue, 20 Jun 2017 23:30:25 +0000
reviewersmattn
bugs1372427
milestone56.0a1
Bug 1372427 - enforce balanced-listeners. r=mattn MozReview-Commit-ID: KpPZA2godKg
toolkit/components/satchel/.eslintrc.js
toolkit/components/satchel/test/test_popup_enter_event.html
--- 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();