-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow <input type=image> to submit forms
- Loading branch information
Showing
2 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...eb-platform-tests/to-upstream/html/semantics/forms/form-submission-0/form-submitters.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>HTML Test: form submitters</title> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#form-submission-algorithm"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<body> | ||
<script> | ||
"use strict"; | ||
|
||
let isSubmitted; | ||
function prepareForm() { | ||
isSubmitted = false; | ||
const form = document.createElement("FORM"); | ||
form.addEventListener("submit", event => { | ||
event.preventDefault(); | ||
isSubmitted = true; | ||
}); | ||
document.body.appendChild(form); | ||
form.innerHTML = ` | ||
<button type="submit" /> | ||
<button type="button" /> | ||
<input type="submit" /> | ||
<input type="image" /> | ||
<input type="text" /> | ||
`; | ||
return form; | ||
} | ||
|
||
test(() => { | ||
const form = prepareForm(); | ||
form.querySelector("button[type=submit]").click(); | ||
assert_true(isSubmitted, "Form is submitted"); | ||
}, "Form is submitted by submit buttons"); | ||
|
||
test(() => { | ||
const form = prepareForm(); | ||
form.querySelector("button[type=button]").click(); | ||
assert_false(isSubmitted, "Form is not submitted"); | ||
}, "Form is not submitted by other button types"); | ||
|
||
test(() => { | ||
const form = prepareForm(); | ||
form.querySelector("input[type=submit]").click(); | ||
assert_true(isSubmitted, "Form is submitted"); | ||
}, "Form is submitted by submit inputs"); | ||
|
||
test(() => { | ||
const form = prepareForm(); | ||
form.querySelector("input[type=image]").click(); | ||
assert_true(isSubmitted, "Form is submitted"); | ||
}, "Form is submitted by image inputs"); | ||
|
||
test(() => { | ||
const form = prepareForm(); | ||
form.querySelector("input[type=text]").click(); | ||
assert_false(isSubmitted, "Form is not submitted"); | ||
}, "Form is not submitted by other input types"); | ||
</script> |