mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-12 11:09:18 +00:00
LibWeb: Implement HTMLInputElement type=url constraint validation
This change implements HTMLInputElement type=url constraint validation in such a way as to match the behavior in other existing engines (which is, however, very different from what the spec currently requires).
This commit is contained in:
parent
6606eecce5
commit
38197916c3
Notes:
github-actions[bot]
2025-03-04 19:16:38 +00:00
Author: https://github.com/sideshowbarker
Commit: 38197916c3
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3743
Reviewed-by: https://github.com/tcl3 ✅
3 changed files with 13 additions and 9 deletions
|
@ -15,6 +15,7 @@
|
||||||
#include <LibJS/Runtime/Date.h>
|
#include <LibJS/Runtime/Date.h>
|
||||||
#include <LibJS/Runtime/NativeFunction.h>
|
#include <LibJS/Runtime/NativeFunction.h>
|
||||||
#include <LibJS/Runtime/RegExpObject.h>
|
#include <LibJS/Runtime/RegExpObject.h>
|
||||||
|
#include <LibURL/Parser.h>
|
||||||
#include <LibWeb/Bindings/HTMLInputElementPrototype.h>
|
#include <LibWeb/Bindings/HTMLInputElementPrototype.h>
|
||||||
#include <LibWeb/Bindings/PrincipalHostDefined.h>
|
#include <LibWeb/Bindings/PrincipalHostDefined.h>
|
||||||
#include <LibWeb/CSS/ComputedProperties.h>
|
#include <LibWeb/CSS/ComputedProperties.h>
|
||||||
|
@ -3044,12 +3045,15 @@ bool HTMLInputElement::suffering_from_being_missing() const
|
||||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-a-type-mismatch
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-a-type-mismatch
|
||||||
bool HTMLInputElement::suffering_from_a_type_mismatch() const
|
bool HTMLInputElement::suffering_from_a_type_mismatch() const
|
||||||
{
|
{
|
||||||
|
auto input = value();
|
||||||
switch (type_state()) {
|
switch (type_state()) {
|
||||||
case TypeAttributeState::URL:
|
case TypeAttributeState::URL:
|
||||||
// https://html.spec.whatwg.org/multipage/input.html#url-state-(type%3Durl)%3Asuffering-from-a-type-mismatch
|
// https://html.spec.whatwg.org/multipage/input.html#url-state-(type%3Durl)%3Asuffering-from-a-type-mismatch
|
||||||
// While the value of the element is neither the empty string nor a valid absolute URL, the element is suffering from a type mismatch.
|
// While the value of the element is neither the empty string nor a valid absolute URL, the element is suffering from a type mismatch.
|
||||||
// FIXME: Implement this.
|
// AD-HOC: https://github.com/whatwg/html/issues/11083 and https://github.com/web-platform-tests/wpt/pull/51011
|
||||||
break;
|
// We intentionally don't check if the value is a "valid absolute URL", because that's not what other
|
||||||
|
// engines actually do. So we instead just implement what matches the behavior in existing engines.
|
||||||
|
return !input.is_empty() && !URL::Parser::basic_parse(input).has_value();
|
||||||
case TypeAttributeState::Email:
|
case TypeAttributeState::Email:
|
||||||
// https://html.spec.whatwg.org/multipage/input.html#email-state-(type%3Demail)%3Asuffering-from-a-type-mismatch
|
// https://html.spec.whatwg.org/multipage/input.html#email-state-(type%3Demail)%3Asuffering-from-a-type-mismatch
|
||||||
// While the value of the element is neither the empty string nor a single valid email address, the element is suffering from a type mismatch.
|
// While the value of the element is neither the empty string nor a single valid email address, the element is suffering from a type mismatch.
|
||||||
|
|
|
@ -2,8 +2,8 @@ Harness status: OK
|
||||||
|
|
||||||
Found 130 tests
|
Found 130 tests
|
||||||
|
|
||||||
112 Pass
|
114 Pass
|
||||||
18 Fail
|
16 Fail
|
||||||
Pass [INPUT in TEXT status] no constraint
|
Pass [INPUT in TEXT status] no constraint
|
||||||
Pass [INPUT in TEXT status] no constraint (in a form)
|
Pass [INPUT in TEXT status] no constraint (in a form)
|
||||||
Pass [INPUT in TEXT status] not suffering from being too long
|
Pass [INPUT in TEXT status] not suffering from being too long
|
||||||
|
@ -42,8 +42,8 @@ Pass [INPUT in URL status] suffering from being too long
|
||||||
Pass [INPUT in URL status] suffering from being too long (in a form)
|
Pass [INPUT in URL status] suffering from being too long (in a form)
|
||||||
Pass [INPUT in URL status] suffering from a pattern mismatch
|
Pass [INPUT in URL status] suffering from a pattern mismatch
|
||||||
Pass [INPUT in URL status] suffering from a pattern mismatch (in a form)
|
Pass [INPUT in URL status] suffering from a pattern mismatch (in a form)
|
||||||
Fail [INPUT in URL status] suffering from a type mismatch
|
Pass [INPUT in URL status] suffering from a type mismatch
|
||||||
Fail [INPUT in URL status] suffering from a type mismatch (in a form)
|
Pass [INPUT in URL status] suffering from a type mismatch (in a form)
|
||||||
Pass [INPUT in URL status] suffering from being missing
|
Pass [INPUT in URL status] suffering from being missing
|
||||||
Pass [INPUT in URL status] suffering from being missing (in a form)
|
Pass [INPUT in URL status] suffering from being missing (in a form)
|
||||||
Pass [INPUT in EMAIL status] no constraint
|
Pass [INPUT in EMAIL status] no constraint
|
||||||
|
|
|
@ -2,8 +2,8 @@ Harness status: OK
|
||||||
|
|
||||||
Found 11 tests
|
Found 11 tests
|
||||||
|
|
||||||
7 Pass
|
8 Pass
|
||||||
4 Fail
|
3 Fail
|
||||||
Pass [INPUT in EMAIL status] The value is empty
|
Pass [INPUT in EMAIL status] The value is empty
|
||||||
Pass [INPUT in EMAIL status] The value is a valid email address
|
Pass [INPUT in EMAIL status] The value is a valid email address
|
||||||
Pass [INPUT in EMAIL status] The value is a valid email address with some white spaces.
|
Pass [INPUT in EMAIL status] The value is a valid email address with some white spaces.
|
||||||
|
@ -14,4 +14,4 @@ Fail [INPUT in EMAIL status] The value contains invalid separator
|
||||||
Pass [INPUT in URL status] The value is empty
|
Pass [INPUT in URL status] The value is empty
|
||||||
Pass [INPUT in URL status] The value is a valid url
|
Pass [INPUT in URL status] The value is a valid url
|
||||||
Pass [INPUT in URL status] The value is a valid url with some white spaces.
|
Pass [INPUT in URL status] The value is a valid url with some white spaces.
|
||||||
Fail [INPUT in URL status] The value is not an url
|
Pass [INPUT in URL status] The value is not an url
|
Loading…
Add table
Add a link
Reference in a new issue