mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:27:45 +00:00
LibWeb: Implement HTMLFormElement.requestSubmit()
This can be used to submit a form using a specific submit button.
This commit is contained in:
parent
94149db073
commit
816d24f647
5 changed files with 72 additions and 1 deletions
4
Tests/LibWeb/Text/expected/form-requestSubmit.txt
Normal file
4
Tests/LibWeb/Text/expected/form-requestSubmit.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
Submitter is null
|
||||
<INPUT id="form-associated-button" >
|
||||
Exception: NotFoundError
|
||||
Exception: TypeError
|
41
Tests/LibWeb/Text/input/form-requestSubmit.html
Normal file
41
Tests/LibWeb/Text/input/form-requestSubmit.html
Normal file
|
@ -0,0 +1,41 @@
|
|||
<!DOCTYPE html>
|
||||
<span id="not-a-submit-button"></span>
|
||||
<form>
|
||||
<input type="Submit" id="form-associated-button" />
|
||||
</form>
|
||||
<input type="Submit" id="other-button" />
|
||||
<script src="./include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
const form = document.forms[0];
|
||||
form.addEventListener("submit", event => {
|
||||
event.preventDefault();
|
||||
if (event.submitter) {
|
||||
printElement(event.submitter);
|
||||
} else {
|
||||
println("Submitter is null");
|
||||
}
|
||||
});
|
||||
|
||||
form.requestSubmit();
|
||||
|
||||
const formAssociatedButton = document.getElementById("form-associated-button");
|
||||
form.requestSubmit(formAssociatedButton);
|
||||
|
||||
const otherButton = document.getElementById("other-button");
|
||||
try {
|
||||
form.requestSubmit(otherButton);
|
||||
println("FAIL");
|
||||
} catch (e) {
|
||||
println(`Exception: ${e.name}`);
|
||||
}
|
||||
|
||||
const notASubmitButton = document.getElementById("not-a-submit-button");
|
||||
try {
|
||||
form.requestSubmit(notASubmitButton);
|
||||
println("FAIL");
|
||||
} catch (e) {
|
||||
println(`Exception: ${e.name}`);
|
||||
}
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue