diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Libraries/LibWeb/HTML/HTMLInputElement.cpp
index d55be7b28d4..6ed8ac531e3 100644
--- a/Libraries/LibWeb/HTML/HTMLInputElement.cpp
+++ b/Libraries/LibWeb/HTML/HTMLInputElement.cpp
@@ -15,6 +15,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -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
bool HTMLInputElement::suffering_from_a_type_mismatch() const
{
+ auto input = value();
switch (type_state()) {
case TypeAttributeState::URL:
// 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.
- // FIXME: Implement this.
- break;
+ // AD-HOC: https://github.com/whatwg/html/issues/11083 and https://github.com/web-platform-tests/wpt/pull/51011
+ // 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:
// 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.
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/constraints/form-validation-checkValidity.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/constraints/form-validation-checkValidity.txt
index 949fb7e1097..2dc073bf2c5 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/constraints/form-validation-checkValidity.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/constraints/form-validation-checkValidity.txt
@@ -2,8 +2,8 @@ Harness status: OK
Found 130 tests
-112 Pass
-18 Fail
+114 Pass
+16 Fail
Pass [INPUT in TEXT status] no constraint
Pass [INPUT in TEXT status] no constraint (in a form)
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 a pattern mismatch
Pass [INPUT in URL status] suffering from a pattern mismatch (in a form)
-Fail [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
+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 (in a form)
Pass [INPUT in EMAIL status] no constraint
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/constraints/form-validation-validity-typeMismatch.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/constraints/form-validation-validity-typeMismatch.txt
index 0768bad0669..db07b781542 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/constraints/form-validation-validity-typeMismatch.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/constraints/form-validation-validity-typeMismatch.txt
@@ -2,8 +2,8 @@ Harness status: OK
Found 11 tests
-7 Pass
-4 Fail
+8 Pass
+3 Fail
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 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 a valid url
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
\ No newline at end of file
+Pass [INPUT in URL status] The value is not an url
\ No newline at end of file