New issue
Advanced search Search tips

Issue 730108 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Closed: Jun 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

In theory, dispatchEvent(new Event('submit')) should not be preventDefault()able

Reported by jkerom...@mozilla.com, Jun 6 2017

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0

Steps to reproduce the problem:
1. Navigate to this address:

data:text/html,
<form action="https://www.mozilla.org/" id="form">
  <input type="submit" value="Navigate maybe">
</form>
<script>
  var form = document.getElementById("form");
  form.addEventListener("submit", function (event) {
    console.log(event.cancelable);
    event.preventDefault();
  });
  form.dispatchEvent(new Event('submit'));
</script>

What is the expected behavior?
The form is expected to navigate away to https://www.mozilla.org/ (form.action)

What went wrong?
The form doesn't navigate away.

I'm not sure if this spec-violation is a bug, or if it's intended as a convenience to developers (I agree that my code looks like I'm trying to make the <form> not navigate away).

Did this work before? N/A 

Does this work in other browsers? N/A

Chrome version: 58.0.3029.110 (Official Build) (64-bit)  Channel: stable
OS Version: 10.0
Flash Version: 

In my "submit" handler, `event.cancelable === false`, and `dispatchEvent()` returns `true` (i.e. "event wasn't canceled"), however the form still doesn't navigate away.

Firefox honors the spec behavior, so I've filed a Firefox webcompat bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1370630
 
Labels: Hotlist-Interop

Comment 2 by woxxom@gmail.com, Jun 6 2017

The form submission algorithm spec [1] describes only a cancelable 'submit' event so Chromium implementation might have simply overlooked the non-cancelable case. Just my 2c.

  [1]: https://html.spec.whatwg.org/multipage/forms.html#form-submission-algorithm
Components: Blink>Forms

Comment 4 by tkent@chromium.org, Jun 15 2017

Components: -Blink>Forms Blink>Forms>Submission
Owner: tkent@chromium.org
Status: WontFix (was: Unconfirmed)
This is a bug of Firefox. Dispatching non-trusted 'submit' event should not start form submission.  The specification doesn't define such behavior AFAIK.

Sign in to add a comment