mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-26 12:17:52 +00:00
LibWeb: Validate form submissions whose submitter is not form-associated
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
The spec for checking the no-validate state ends with a default return value of "false". However, we were only hitting this case for form- associated elements. If the submitter is the form itself, we want to enter the form validation steps.
This commit is contained in:
parent
23aadc02ca
commit
017ae80668
Notes:
github-actions[bot]
2025-08-15 13:29:42 +00:00
Author: https://github.com/trflynn89
Commit: 017ae80668
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5863
Reviewed-by: https://github.com/gmta ✅
2 changed files with 14 additions and 4 deletions
|
@ -96,6 +96,16 @@ WebIDL::ExceptionOr<void> HTMLFormElement::implicitly_submit_form()
|
|||
return {};
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-fs-novalidate
|
||||
static bool novalidate_state(HTMLElement const& element)
|
||||
{
|
||||
// The no-validate state of an element is true if the element is a submit button and the element's formnovalidate
|
||||
// attribute is present, or if the element's form owner's novalidate attribute is present, and false otherwise.
|
||||
if (auto const* form_associated_element = as_if<FormAssociatedElement>(element))
|
||||
return form_associated_element->novalidate_state();
|
||||
return false;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-form-submit
|
||||
WebIDL::ExceptionOr<void> HTMLFormElement::submit_form(GC::Ref<HTMLElement> submitter, SubmitFormOptions options)
|
||||
{
|
||||
|
@ -142,8 +152,7 @@ WebIDL::ExceptionOr<void> HTMLFormElement::submit_form(GC::Ref<HTMLElement> subm
|
|||
// 4. If the submitter element's no-validate state is false, then interactively validate the constraints
|
||||
// of form and examine the result. If the result is negative (i.e., the constraint validation concluded
|
||||
// that there were invalid fields and probably informed the user of this), then:
|
||||
auto* form_associated_element = as_if<FormAssociatedElement>(*submitter);
|
||||
if (form_associated_element && !form_associated_element->novalidate_state()) {
|
||||
if (!novalidate_state(submitter)) {
|
||||
auto validation_result = interactively_validate_constraints();
|
||||
if (!validation_result) {
|
||||
// 1. Set form's firing submission events to false.
|
||||
|
|
|
@ -2,6 +2,7 @@ Harness status: OK
|
|||
|
||||
Found 2 tests
|
||||
|
||||
2 Fail
|
||||
1 Pass
|
||||
1 Fail
|
||||
Fail Validation for placeholder option
|
||||
Fail Check form not submitted for invalid select
|
||||
Pass Check form not submitted for invalid select
|
Loading…
Add table
Add a link
Reference in a new issue