mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
LibWeb: Check if input is disabled before submit event to form
This commit is contained in:
parent
b4df14ebe5
commit
c2cc0d9cd0
Notes:
github-actions[bot]
2025-02-05 21:47:22 +00:00
Author: https://github.com/FMMazur Commit: https://github.com/LadybirdBrowser/ladybird/commit/c2cc0d9cd0a Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3254 Reviewed-by: https://github.com/ADKaster ✅
2 changed files with 17 additions and 6 deletions
|
@ -6,6 +6,7 @@
|
|||
* Copyright (c) 2023, Bastiaan van der Plaat <bastiaan.v.d.plaat@gmail.com>
|
||||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
||||
* Copyright (c) 2024, Fernando Kiotheka <fer@k6a.dev>
|
||||
* Copyright (c) 2025, Felipe Muñoz Mazur <felipe.munoz.mazur@protonmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -376,8 +377,15 @@ WebIDL::ExceptionOr<void> HTMLInputElement::run_input_activation_behavior(DOM::E
|
|||
auto change_event = DOM::Event::create(realm(), HTML::EventNames::change);
|
||||
change_event->set_bubbles(true);
|
||||
dispatch_event(*change_event);
|
||||
} else if (type_state() == TypeAttributeState::SubmitButton) {
|
||||
}
|
||||
// https://html.spec.whatwg.org/multipage/input.html#submit-button-state-(type=submit)
|
||||
else if (type_state() == TypeAttributeState::SubmitButton) {
|
||||
GC::Ptr<HTMLFormElement> form;
|
||||
|
||||
// The input element represents a button that, when activated, submits the form.
|
||||
if (is_actually_disabled())
|
||||
return {};
|
||||
|
||||
// 1. If the element does not have a form owner, then return.
|
||||
if (!(form = this->form()))
|
||||
return {};
|
||||
|
@ -418,6 +426,10 @@ WebIDL::ExceptionOr<void> HTMLInputElement::run_input_activation_behavior(DOM::E
|
|||
}
|
||||
// https://html.spec.whatwg.org/multipage/input.html#reset-button-state-(type=reset)
|
||||
else if (type_state() == TypeAttributeState::ResetButton) {
|
||||
// The input element represents a button that, when activated, resets the form.
|
||||
if (is_actually_disabled())
|
||||
return {};
|
||||
|
||||
// 1. If the element does not have a form owner, then return.
|
||||
auto* form = this->form();
|
||||
if (!form)
|
||||
|
|
|
@ -2,8 +2,7 @@ Harness status: OK
|
|||
|
||||
Found 33 tests
|
||||
|
||||
30 Pass
|
||||
3 Fail
|
||||
33 Pass
|
||||
Pass basic with click()
|
||||
Pass basic with dispatchEvent()
|
||||
Pass basic with wrong event class
|
||||
|
@ -34,6 +33,6 @@ Pass disabling checkbox in onclick listener shouldn't suppress onchange
|
|||
Pass disabling radio in onclick listener shouldn't suppress oninput
|
||||
Pass disabling radio in onclick listener shouldn't suppress onchange
|
||||
Pass disconnected form should not submit
|
||||
Fail disabled submit button should not activate
|
||||
Fail submit button should not activate if the event listener disables it
|
||||
Fail submit button that morphed from checkbox should not activate
|
||||
Pass disabled submit button should not activate
|
||||
Pass submit button should not activate if the event listener disables it
|
||||
Pass submit button that morphed from checkbox should not activate
|
Loading…
Add table
Reference in a new issue