diff --git a/Libraries/LibWeb/HTML/ElementInternals.cpp b/Libraries/LibWeb/HTML/ElementInternals.cpp
index 53479232e50..ea612465676 100644
--- a/Libraries/LibWeb/HTML/ElementInternals.cpp
+++ b/Libraries/LibWeb/HTML/ElementInternals.cpp
@@ -108,15 +108,17 @@ WebIDL::ExceptionOr ElementInternals::set_validity(ValidityStateFlags cons
// FIXME: 6. If element's customError validity flag is true, then set element's custom validity error message to element's validation message. Otherwise, set element's custom validity error message to the empty string.
- // FIXME: 7. Set element's validation anchor to null if anchor is not given. Otherwise, if anchor is not a shadow-including descendant of element, then throw a "NotFoundError" DOMException. Otherwise, set element's validation anchor to anchor.
+ // 7. If anchor is not given, then set it to element.
if (!anchor.has_value() || !anchor.value().ptr()) {
- // FIXME
- } else if (!anchor.value()->is_shadow_including_descendant_of(element)) {
- return WebIDL::NotFoundError::create(realm(), "Anchor is not a shadow-including descendant of element"_string);
- } else {
- // FIXME
+ anchor = element;
}
+ // 8. Otherwise, if anchor is not a shadow-including inclusive descendant of element, then throw a "NotFoundError" DOMException.
+ else if (!anchor.value()->is_shadow_including_inclusive_descendant_of(element)) {
+ return WebIDL::NotFoundError::create(realm(), "Anchor is not a shadow-including descendant of element"_string);
+ }
+
+ // FIXME: 9. Set element's validation anchor to anchor.
dbgln("FIXME: ElementInternals::set_validity()");
return {};
}
diff --git a/Tests/LibWeb/Text/expected/wpt-import/custom-elements/form-associated/ElementInternals-validation.txt b/Tests/LibWeb/Text/expected/wpt-import/custom-elements/form-associated/ElementInternals-validation.txt
new file mode 100644
index 00000000000..4c50fa1d248
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/custom-elements/form-associated/ElementInternals-validation.txt
@@ -0,0 +1,20 @@
+Harness status: OK
+
+Found 14 tests
+
+6 Pass
+8 Fail
+Fail willValidate
+Fail willValidate after upgrade
+Pass willValidate after upgrade (document.createElement)
+Pass willValidate should throw NotSupportedError if the target element is not a form-associated custom element
+Fail validity and setValidity()
+Fail validity.customError should be false if not explicitly set via setValidity()
+Pass "anchor" argument of setValidity()
+Pass "anchor" argument of setValidity(): passing self
+Pass checkValidity() should throw NotSupportedError if the target element is not a form-associated custom element
+Fail checkValidity()
+Pass reportValidity() should throw NotSupportedError if the target element is not a form-associated custom element
+Fail reportValidity()
+Fail Custom control affects validation at the owner form
+Fail Custom control affects :valid :invalid for FORM and FIELDSET
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/custom-elements/form-associated/ElementInternals-validation.html b/Tests/LibWeb/Text/input/wpt-import/custom-elements/form-associated/ElementInternals-validation.html
new file mode 100644
index 00000000000..2cd150bf21e
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/custom-elements/form-associated/ElementInternals-validation.html
@@ -0,0 +1,357 @@
+
+Form validation features of ElementInternals, and :valid :invalid pseudo classes
+
+
+
+
+
+