mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-02 14:19:15 +00:00
LibWeb: Implement validation_message for form associated elements
It wins us a quick WPT test as well as implement a bunch of IDL methods.
This commit is contained in:
parent
8ab568bc76
commit
70c3f203ef
Notes:
github-actions[bot]
2025-08-29 18:28:51 +00:00
Author: https://github.com/tete17
Commit: 70c3f203ef
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6024
Reviewed-by: https://github.com/tcl3 ✅
10 changed files with 30 additions and 10 deletions
|
@ -259,6 +259,24 @@ bool FormAssociatedElement::will_validate() const
|
||||||
return is_candidate_for_constraint_validation();
|
return is_candidate_for_constraint_validation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-validationmessage
|
||||||
|
Utf16String FormAssociatedElement::validation_message() const
|
||||||
|
{
|
||||||
|
// 1. If this element is not a candidate for constraint validation or if this element satisfies its constraints,
|
||||||
|
// then return the empty string.
|
||||||
|
if (!is_candidate_for_constraint_validation() || satisfies_its_constraints())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
// FIXME
|
||||||
|
// 2. Return a suitably localized message that the user agent would show the user if this were the only form
|
||||||
|
// control with a validity constraint problem. If the user agent would not actually show a textual message in
|
||||||
|
// such a situation (e.g., it would show a graphical cue instead), then return a suitably localized message that
|
||||||
|
// expresses (one or more of) the validity constraint(s) that the control does not satisfy. If the element is a
|
||||||
|
// candidate for constraint validation and is suffering from a custom error, then the custom validity error
|
||||||
|
// message should be present in the return value.
|
||||||
|
return "Invalid form"_utf16;
|
||||||
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#check-validity-steps
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#check-validity-steps
|
||||||
bool FormAssociatedElement::check_validity_steps()
|
bool FormAssociatedElement::check_validity_steps()
|
||||||
{
|
{
|
||||||
|
|
|
@ -149,6 +149,9 @@ public:
|
||||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-willvalidate
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-willvalidate
|
||||||
bool will_validate() const;
|
bool will_validate() const;
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-validationmessage
|
||||||
|
Utf16String validation_message() const;
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-validity
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-validity
|
||||||
GC::Ref<ValidityState const> validity() const;
|
GC::Ref<ValidityState const> validity() const;
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ interface HTMLButtonElement : HTMLElement {
|
||||||
|
|
||||||
readonly attribute boolean willValidate;
|
readonly attribute boolean willValidate;
|
||||||
readonly attribute ValidityState validity;
|
readonly attribute ValidityState validity;
|
||||||
[FIXME] readonly attribute DOMString validationMessage;
|
readonly attribute Utf16DOMString validationMessage;
|
||||||
boolean checkValidity();
|
boolean checkValidity();
|
||||||
boolean reportValidity();
|
boolean reportValidity();
|
||||||
undefined setCustomValidity(DOMString error);
|
undefined setCustomValidity(DOMString error);
|
||||||
|
|
|
@ -16,7 +16,7 @@ interface HTMLFieldSetElement : HTMLElement {
|
||||||
|
|
||||||
readonly attribute boolean willValidate;
|
readonly attribute boolean willValidate;
|
||||||
[FIXME, SameObject] readonly attribute ValidityState validity;
|
[FIXME, SameObject] readonly attribute ValidityState validity;
|
||||||
[FIXME] readonly attribute DOMString validationMessage;
|
readonly attribute Utf16DOMString validationMessage;
|
||||||
boolean checkValidity();
|
boolean checkValidity();
|
||||||
boolean reportValidity();
|
boolean reportValidity();
|
||||||
undefined setCustomValidity(DOMString error);
|
undefined setCustomValidity(DOMString error);
|
||||||
|
|
|
@ -54,7 +54,7 @@ interface HTMLInputElement : HTMLElement {
|
||||||
|
|
||||||
readonly attribute boolean willValidate;
|
readonly attribute boolean willValidate;
|
||||||
readonly attribute ValidityState validity;
|
readonly attribute ValidityState validity;
|
||||||
[FIXME] readonly attribute DOMString validationMessage;
|
readonly attribute Utf16DOMString validationMessage;
|
||||||
boolean checkValidity();
|
boolean checkValidity();
|
||||||
boolean reportValidity();
|
boolean reportValidity();
|
||||||
undefined setCustomValidity(DOMString error);
|
undefined setCustomValidity(DOMString error);
|
||||||
|
|
|
@ -20,7 +20,7 @@ interface HTMLObjectElement : HTMLElement {
|
||||||
|
|
||||||
readonly attribute boolean willValidate;
|
readonly attribute boolean willValidate;
|
||||||
readonly attribute ValidityState validity;
|
readonly attribute ValidityState validity;
|
||||||
[FIXME] readonly attribute DOMString validationMessage;
|
readonly attribute Utf16DOMString validationMessage;
|
||||||
boolean checkValidity();
|
boolean checkValidity();
|
||||||
boolean reportValidity();
|
boolean reportValidity();
|
||||||
undefined setCustomValidity(DOMString error);
|
undefined setCustomValidity(DOMString error);
|
||||||
|
|
|
@ -17,7 +17,7 @@ interface HTMLOutputElement : HTMLElement {
|
||||||
|
|
||||||
readonly attribute boolean willValidate;
|
readonly attribute boolean willValidate;
|
||||||
readonly attribute ValidityState validity;
|
readonly attribute ValidityState validity;
|
||||||
[FIXME] readonly attribute DOMString validationMessage;
|
readonly attribute Utf16DOMString validationMessage;
|
||||||
boolean checkValidity();
|
boolean checkValidity();
|
||||||
boolean reportValidity();
|
boolean reportValidity();
|
||||||
undefined setCustomValidity(DOMString error);
|
undefined setCustomValidity(DOMString error);
|
||||||
|
|
|
@ -33,7 +33,7 @@ interface HTMLSelectElement : HTMLElement {
|
||||||
|
|
||||||
readonly attribute boolean willValidate;
|
readonly attribute boolean willValidate;
|
||||||
readonly attribute ValidityState validity;
|
readonly attribute ValidityState validity;
|
||||||
[FIXME] readonly attribute DOMString validationMessage;
|
readonly attribute Utf16DOMString validationMessage;
|
||||||
boolean checkValidity();
|
boolean checkValidity();
|
||||||
boolean reportValidity();
|
boolean reportValidity();
|
||||||
undefined setCustomValidity(DOMString error);
|
undefined setCustomValidity(DOMString error);
|
||||||
|
|
|
@ -28,7 +28,7 @@ interface HTMLTextAreaElement : HTMLElement {
|
||||||
|
|
||||||
readonly attribute boolean willValidate;
|
readonly attribute boolean willValidate;
|
||||||
readonly attribute ValidityState validity;
|
readonly attribute ValidityState validity;
|
||||||
[FIXME] readonly attribute DOMString validationMessage;
|
readonly attribute Utf16DOMString validationMessage;
|
||||||
boolean checkValidity();
|
boolean checkValidity();
|
||||||
boolean reportValidity();
|
boolean reportValidity();
|
||||||
undefined setCustomValidity(DOMString error);
|
undefined setCustomValidity(DOMString error);
|
||||||
|
|
|
@ -2,8 +2,7 @@ Harness status: OK
|
||||||
|
|
||||||
Found 78 tests
|
Found 78 tests
|
||||||
|
|
||||||
77 Pass
|
78 Pass
|
||||||
1 Fail
|
|
||||||
Pass [INPUT in TEXT status] The required attribute is not set
|
Pass [INPUT in TEXT status] The required attribute is not set
|
||||||
Pass [INPUT in TEXT status] The value is not empty and required is true
|
Pass [INPUT in TEXT status] The value is not empty and required is true
|
||||||
Pass [INPUT in TEXT status] The value is empty and required is true
|
Pass [INPUT in TEXT status] The value is empty and required is true
|
||||||
|
@ -81,4 +80,4 @@ Pass [select] Selected the option with value equals to empty
|
||||||
Pass [textarea] The required attribute is not set
|
Pass [textarea] The required attribute is not set
|
||||||
Pass [textarea] The value is not empty
|
Pass [textarea] The value is not empty
|
||||||
Pass [textarea] The value is empty
|
Pass [textarea] The value is empty
|
||||||
Fail validationMessage should return empty string when willValidate is false and valueMissing is true
|
Pass validationMessage should return empty string when willValidate is false and valueMissing is true
|
Loading…
Add table
Add a link
Reference in a new issue