Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Hidden buttons can't be used as the submitter in an implicit submission
https://bugs.webkit.org/show_bug.cgi?id=247545 Reviewed by Chris Dumez. Removed the check for renderer to match the behaviors of other browsers and HTML5 spec: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#implicit-submission * LayoutTests/fast/forms/submit-form-with-hidden-button-expected.txt: Added. * LayoutTests/fast/forms/submit-form-with-hidden-button.html: Added. * Source/WebCore/html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::submitImplicitly): Canonical link: https://commits.webkit.org/256813@main
- Loading branch information
Showing
3 changed files
with
42 additions
and
4 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Tests implicitly submitting with a hidden button. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS submitter.id is "hiddenButton" | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
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,30 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<form id="form"> | ||
<input id="text1" name="text1" value="Press Enter" autofocus> | ||
<input id="hiddenButton" type="submit" name="hiddenButton" value="Success" hidden> | ||
<input id="secondButton" type="submit" name="secondButton" value="Fail" style="visibility: hidden"> | ||
</form> | ||
<script src="../../resources/js-test.js"></script> | ||
<script> | ||
description('Tests implicitly submitting with a hidden button.'); | ||
|
||
let submitter = null; | ||
form.addEventListener("submit", event => { | ||
submitter = event.submitter; | ||
event.preventDefault(); | ||
}); | ||
|
||
text1.focus(); | ||
|
||
const enterKeyEvent = new KeyboardEvent('keypress', { bubbles: true, cancelable: true, view: window, detail: 0, | ||
key: 'Enter', code: 'Enter', keyIdentifier: '', keyCode: 13, charCode: 13, which: 13, | ||
location: 0, ctrlKey: false, altKey: false, shiftKey: false, metaKey: false }); | ||
text1.dispatchEvent(enterKeyEvent); | ||
|
||
shouldBeEqualToString('submitter.id', 'hiddenButton'); | ||
|
||
</script> | ||
</body> | ||
</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