diff --git a/Libraries/LibWeb/HTML/HTMLButtonElement.cpp b/Libraries/LibWeb/HTML/HTMLButtonElement.cpp
index f5bfe431938..1e4b836dd54 100644
--- a/Libraries/LibWeb/HTML/HTMLButtonElement.cpp
+++ b/Libraries/LibWeb/HTML/HTMLButtonElement.cpp
@@ -137,14 +137,19 @@ void HTMLButtonElement::activation_behavior(DOM::Event const& event)
// 3. If element has a form owner:
if (form() != nullptr) {
- // 1. If element is a submit button, then submit element's form owner from element with userInvolvement set to event's user navigation involvement.
+ // 1. If element is a submit button, then submit element's form owner from element with userInvolvement set to event's user navigation involvement, and return.
if (is_submit_button()) {
form()->submit_form(*this, { .user_involvement = user_navigation_involvement(event) }).release_value_but_fixme_should_propagate_errors();
+ return;
}
- // 2. If element's type attribute is in the Reset Button state, then reset element's form owner.
+ // 2. If element's type attribute is in the Reset Button state, then reset element's form owner, and return.
if (type_state() == TypeAttributeState::Reset) {
form()->reset_form();
+ return;
}
+ // 3. If element's type attribute is in the Auto state, then return.
+ if (type_state() == TypeAttributeState::Auto)
+ return;
}
// FIXME: 4. Let target be the result of running element's get the commandfor associated element.
diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Libraries/LibWeb/HTML/HTMLInputElement.cpp
index 378d6690997..960770021e7 100644
--- a/Libraries/LibWeb/HTML/HTMLInputElement.cpp
+++ b/Libraries/LibWeb/HTML/HTMLInputElement.cpp
@@ -2696,7 +2696,11 @@ void HTMLInputElement::activation_behavior(DOM::Event const& event)
// 2. Run this element's input activation behavior, if any, and do nothing otherwise.
run_input_activation_behavior(event).release_value_but_fixme_should_propagate_errors();
- // 3. Run the popover target attribute activation behavior given element and event's target.
+ // 3. If element has a form owner and element's type attribute is not in the Button state, then return.
+ if (form() != nullptr && type_state() != TypeAttributeState::Button)
+ return;
+
+ // 4. Run the popover target attribute activation behavior given element and event's target.
if (event.target() && event.target()->is_dom_node())
PopoverInvokerElement::popover_target_activation_behaviour(*this, as(*event.target()));
}
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/popovers/button-type-popovertarget.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/popovers/button-type-popovertarget.txt
new file mode 100644
index 00000000000..a7821be17b0
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/popovers/button-type-popovertarget.txt
@@ -0,0 +1,20 @@
+Harness status: OK
+
+Found 15 tests
+
+15 Pass
+Pass Button type=reset in form should trigger form reset and not toggle popover
+Pass Button type=submit in form should trigger form submit and not toggle popover
+Pass Button type=button in form should toggle popover
+Pass Button type=invalid in form should trigger form submit and not toggle popover
+Pass Button missing type in form should trigger form submit and not toggle popover
+Pass Button type=reset with form attr should trigger form reset and not toggle popover
+Pass Button type=submit with form attr should trigger form submit and not toggle popover
+Pass Button type=button with form attr should toggle popover
+Pass Button type=invalid with form attr should trigger form submit and not toggle popover
+Pass Button missing type with form attr should trigger form submit and not toggle popover
+Pass Button type=reset outside form should toggle popover
+Pass Button type=submit outside form should toggle popover
+Pass Button type=button outside form should toggle popover
+Pass Button type=invalid outside form should toggle popover
+Pass Button missing type outside form should toggle popover
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/popovers/input-type-popovertarget.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/popovers/input-type-popovertarget.txt
new file mode 100644
index 00000000000..2729d2ab4e5
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/popovers/input-type-popovertarget.txt
@@ -0,0 +1,17 @@
+Harness status: OK
+
+Found 12 tests
+
+12 Pass
+Pass input type=reset in form should trigger form reset and not toggle popover
+Pass input type=submit in form should trigger form submit and not toggle popover
+Pass input type=button in form should toggle popover
+Pass input type=image in form should trigger form submit and not toggle popover
+Pass input type=reset with form attr should trigger form reset and not toggle popover
+Pass input type=submit with form attr should trigger form submit and not toggle popover
+Pass input type=button with form attr should toggle popover
+Pass input type=image with form attr should trigger form submit and not toggle popover
+Pass input type=reset outside form should toggle popover
+Pass input type=submit outside form should toggle popover
+Pass input type=button outside form should toggle popover
+Pass input type=image outside form should toggle popover
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/popovers/button-type-popovertarget.html b/Tests/LibWeb/Text/input/wpt-import/html/semantics/popovers/button-type-popovertarget.html
new file mode 100644
index 00000000000..d519b623b7b
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/popovers/button-type-popovertarget.html
@@ -0,0 +1,215 @@
+
+
+
+
+
+
+
+