Bug 1436575 - Add exceptions for cases that cannot be simplified by negation or !! coercion. r?standard8 draft
authorJared Wein <jwein@mozilla.com>
Fri, 09 Feb 2018 10:10:08 -0500
changeset 755656 2b729acd008f2a4e37d55e47f2568c3903e44bf9
parent 755655 f511a41ddb6a4b18661cccf83e8de0d94188446f
child 755657 709849c41bc1f158a418aa4ee58eae0772c95902
push id99234
push userbmo:jaws@mozilla.com
push dateThu, 15 Feb 2018 17:00:17 +0000
reviewersstandard8
bugs1436575
milestone60.0a1
Bug 1436575 - Add exceptions for cases that cannot be simplified by negation or !! coercion. r?standard8 MozReview-Commit-ID: 8uiZAPq4N2h
accessible/tests/mochitest/pivot.js
browser/base/content/tabbrowser.xml
devtools/client/sourceeditor/autocomplete.js
toolkit/content/widgets/colorpicker.xml
toolkit/content/widgets/dialog.xml
--- a/accessible/tests/mochitest/pivot.js
+++ b/accessible/tests/mochitest/pivot.js
@@ -195,17 +195,18 @@ function setVCRangeInvoker(aDocAcc, aTex
  * @param aIdOrNameOrAcc   [in] id, accessible or accessible name to expect
  *                         virtual cursor to land on after performing move method.
  *                         false if no move is expected.
  * @param aIsFromUserInput [in] set user input flag when invoking method, and
  *                         expect it in the event.
  */
 function setVCPosInvoker(aDocAcc, aPivotMoveMethod, aRule, aIdOrNameOrAcc,
                          aIsFromUserInput) {
-  var expectMove = !!aIdOrNameOrAcc;
+  // eslint-disable-next-line mozilla/no-compare-against-boolean-literals
+  var expectMove = aIdOrNameOrAcc != false;
   this.invoke = function virtualCursorChangedInvoker_invoke() {
     VCChangedChecker.
       storePreviousPosAndOffset(aDocAcc.virtualCursor);
     if (aPivotMoveMethod && aRule) {
       var moved = false;
       switch (aPivotMoveMethod) {
         case "moveFirst":
         case "moveLast":
@@ -255,17 +256,18 @@ function setVCPosInvoker(aDocAcc, aPivot
  * @param aIdOrNameOrAcc   [in] id, accessible or accessible name to expect
  *                         virtual cursor to land on after performing move method.
  *                         false if no move is expected.
  * @param aIsFromUserInput [in] set user input flag when invoking method, and
  *                         expect it in the event.
  */
 function setVCTextInvoker(aDocAcc, aPivotMoveMethod, aBoundary, aTextOffsets,
                           aIdOrNameOrAcc, aIsFromUserInput) {
-  var expectMove = !!aIdOrNameOrAcc;
+  // eslint-disable-next-line mozilla/no-compare-against-boolean-literals
+  var expectMove = aIdOrNameOrAcc != false;
   this.invoke = function virtualCursorChangedInvoker_invoke() {
     VCChangedChecker.storePreviousPosAndOffset(aDocAcc.virtualCursor);
     SimpleTest.info(aDocAcc.virtualCursor.position);
     var moved = aDocAcc.virtualCursor[aPivotMoveMethod](aBoundary,
       aIsFromUserInput === undefined);
     SimpleTest.is(!!moved, !!expectMove,
                   "moved pivot by text with " + aPivotMoveMethod +
                   " to " + aIdOrNameOrAcc);
@@ -301,17 +303,18 @@ function setVCTextInvoker(aDocAcc, aPivo
  *                       point.
  * @param aRule          [in] traversal rule object
  * @param aIdOrNameOrAcc [in] id, accessible or accessible name to expect
  *                       virtual cursor to land on after performing move method.
  *                       false if no move is expected.
  */
 function moveVCCoordInvoker(aDocAcc, aX, aY, aIgnoreNoMatch,
                             aRule, aIdOrNameOrAcc) {
-  var expectMove = !!aIdOrNameOrAcc;
+  // eslint-disable-next-line mozilla/no-compare-against-boolean-literals
+  var expectMove = aIdOrNameOrAcc != false;
   this.invoke = function virtualCursorChangedInvoker_invoke() {
     VCChangedChecker.
       storePreviousPosAndOffset(aDocAcc.virtualCursor);
     var moved = aDocAcc.virtualCursor.moveToPoint(aRule, aX, aY,
                                                   aIgnoreNoMatch);
     SimpleTest.ok((expectMove && moved) || (!expectMove && !moved),
                   "moved pivot");
   };
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -494,22 +494,24 @@
                 }
               }
             }
           }
 
           if (!aBrowser)
             aBrowser = this.mCurrentBrowser;
 
-          if (aCallGlobalListeners &&
+          // eslint-disable-next-line mozilla/no-compare-against-boolean-literals
+          if (aCallGlobalListeners != false &&
               aBrowser == this.mCurrentBrowser) {
             callListeners(this.mProgressListeners, aArguments);
           }
 
-          if (aCallTabsListeners) {
+          // eslint-disable-next-line mozilla/no-compare-against-boolean-literals
+          if (aCallTabsListeners != false) {
             aArguments.unshift(aBrowser);
 
             callListeners(this.mTabsProgressListeners, aArguments);
           }
 
           return rv;
         ]]></body>
       </method>
--- a/devtools/client/sourceeditor/autocomplete.js
+++ b/devtools/client/sourceeditor/autocomplete.js
@@ -134,17 +134,18 @@ function initializeAutoCompletion(ctx, o
     position: "bottom",
     theme: "auto",
     autoSelect: true,
     onClick: insertSelectedPopupItem
   });
 
   let cycle = reverse => {
     if (popup && popup.isOpen) {
-      cycleSuggestions(ed, !!reverse);
+      // eslint-disable-next-line mozilla/no-compare-against-boolean-literals
+      cycleSuggestions(ed, reverse == true);
       return null;
     }
 
     return CodeMirror.Pass;
   };
 
   let keyMap = {
     "Tab": cycle,
--- a/toolkit/content/widgets/colorpicker.xml
+++ b/toolkit/content/widgets/colorpicker.xml
@@ -226,17 +226,18 @@
         <![CDATA[
           try {
             var event = document.createEvent("Events");
             event.initEvent(aEventName, true, true);
             var cancel = !aTarget.dispatchEvent(event);
             if (aTarget.hasAttribute("on" + aEventName)) {
               var fn = new Function("event", aTarget.getAttribute("on" + aEventName));
               var rv = fn.call(aTarget, event);
-              if (!rv)
+              // eslint-disable-next-line mozilla/no-compare-against-boolean-literals
+              if (rv == false)
                 cancel = true;
             }
             return !cancel;
           } catch (e) {
             Components.utils.reportError(e);
           }
           return false;
         ]]>
@@ -481,17 +482,18 @@
         <![CDATA[
           try {
             var event = document.createEvent("Events");
             event.initEvent(aEventName, true, true);
             var cancel = !aTarget.dispatchEvent(event);
             if (aTarget.hasAttribute("on" + aEventName)) {
               var fn = new Function("event", aTarget.getAttribute("on" + aEventName));
               var rv = fn.call(aTarget, event);
-              if (!rv)
+              // eslint-disable-next-line mozilla/no-compare-against-boolean-literals
+              if (rv == false)
                 cancel = true;
             }
             return !cancel;
           } catch (e) {
             dump(e);
           }
           return false;
         ]]>
--- a/toolkit/content/widgets/dialog.xml
+++ b/toolkit/content/widgets/dialog.xml
@@ -415,17 +415,18 @@
           // handle dom event handlers
           var noCancel = this.dispatchEvent(event);
 
           // handle any xml attribute event handlers
           var handler = this.getAttribute("ondialog" + aDlgType);
           if (handler != "") {
             var fn = new Function("event", handler);
             var returned = fn(event);
-            if (!returned)
+            // eslint-disable-next-line mozilla/no-compare-against-boolean-literals
+            if (returned == false)
               noCancel = false;
           }
 
           return noCancel;
         ]]>
         </body>
       </method>