Bug 1450345 - prevent form submission for <button> element. r=jorgk a=jorgk
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Fri, 30 Mar 2018 23:18:41 +0300 (2018-03-30)
changeset 28214 2ebcd2081d704f1ed6f36d14bc103cddcc37e0b4
parent 28213 7ff2cfa93818e88db48e850148dc17475318a035
child 28215 eec7161f761fbd8b66527d857b0657743128406f
push id2068
push usermozilla@jorgk.com
push dateWed, 09 May 2018 22:13:55 +0000 (2018-05-09)
treeherdercomm-esr52@d81c08572750 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk, jorgk
bugs1450345
Bug 1450345 - prevent form submission for <button> element. r=jorgk a=jorgk
mail/base/content/contentAreaClick.js
--- a/mail/base/content/contentAreaClick.js
+++ b/mail/base/content/contentAreaClick.js
@@ -2,16 +2,18 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
   /**
    * Extract the href from the link click event.
    * We look for HTMLAnchorElement, HTMLAreaElement, HTMLLinkElement,
    * HTMLInputElement.form.action, and nested anchor tags.
+   * If the clicked element was a HTMLInputElement or HTMLButtonElement
+   * we return the form action.
    *
    * @return href for the url being clicked
    */
 
   Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
   Components.utils.import("resource://gre/modules/Services.jsm");
 
   function hRefForClickEvent(aEvent, aDontCheckInputElement)
@@ -30,17 +32,18 @@
     }
     else if (target instanceof HTMLImageElement &&
              target.hasAttribute("overflowing"))
     {
       // Return if an image is zoomed, otherwise fall through to see if it has
       // a link node.
       return href;
     }
-    else if (!aDontCheckInputElement && target instanceof HTMLInputElement)
+    else if (!aDontCheckInputElement && ((target instanceof HTMLInputElement) ||
+                                         (target instanceof HTMLButtonElement)))
     {
       if (target.form && target.form.action)
         href = target.form.action;
     }
     else
     {
       // We may be nested inside of a link node.
       var linkNode = aEvent.originalTarget;