Skip to content
Permalink
Browse files
submit disabled="disabled" doesn't stop form from being posted with E…
…NTER key

https://bugs.webkit.org/show_bug.cgi?id=243594

Reviewed by Aditya Keerthi.

Change the behavior of WebKit to match that of Blink and Gecko by disallowing
implicit submission of a form when the first submit button is disabled.

* LayoutTests/fast/forms/implicit-submission-expected.txt:
* LayoutTests/fast/forms/implicit-submission.html:
* LayoutTests/platform/mac/fast/forms/implicit-submission-expected.txt:
* LayoutTests/platform/win-7sp0/fast/forms/implicit-submission-expected.txt: Removed.
* LayoutTests/platform/win/fast/forms/implicit-submission-expected.txt:

* Source/WebCore/html/HTMLButtonElement.cpp:
(WebCore::HTMLButtonElement::isSuccessfulSubmitButton const): Changed the condition
to be considered as "successful" submit button.
* Source/WebCore/html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::isSuccessfulSubmitButton const): Ditto.

Canonical link: https://commits.webkit.org/253228@main
  • Loading branch information
rniwa committed Aug 8, 2022
1 parent 29c4919 commit 7f2b47eeff03586875c526e4e5763c8a52c033f8
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 43 deletions.
@@ -1,14 +1,14 @@
Tests various combinations of form elements and how implicit submission works with them.

Single text input should submit: PASS
Single text input with submit disabled should submit: PASS
Single text input with submit disabled should not submit: PASS
Multiple text inputs should not submit: PASS
Multiple text inputs with submit should submit: PASS
Multiple text inputs with submit disabled should not submit: PASS
Multiple text inputs and multiple submits, first submit disabled should submit: PASS
Multiple text inputs and multiple submits, first submit disabled should not submit: PASS
Text input and text area, text input focused should submit: PASS
Text input and text area and a submit, text input focused should submit: PASS
Text input and text area and a disabled submit, text input focused should submit: PASS
Text input and text area and a disabled submit, text input focused should not submit: PASS
Text input and checkbox, text input focused should submit: PASS
Text input and radio, text input focused should submit: PASS
Text input and text area, textarea focused should not submit: PASS
@@ -8,14 +8,14 @@
// match IE and FF unless specified otherwise.
var allTests = [
[ "Single text input", "!text", "y" ],
[ "Single text input with submit disabled", "!text,-submit", "y" ],
[ "Single text input with submit disabled", "!text,-submit", "n" ],
[ "Multiple text inputs", "!text,text,text", "n" ],
[ "Multiple text inputs with submit", "!text,text,text,submit", "y" ],
[ "Multiple text inputs with submit disabled", "!text,text,text,-submit", "n" ],
[ "Multiple text inputs and multiple submits, first submit disabled", "!text,text,text,-submit,submit", "y" ], // match IE, not FF.
[ "Multiple text inputs and multiple submits, first submit disabled", "!text,text,text,-submit,submit", "n" ],
[ "Text input and text area, text input focused", "!text,textarea", "y" ],
[ "Text input and text area and a submit, text input focused", "!text,textarea,submit", "y" ],
[ "Text input and text area and a disabled submit, text input focused", "!text,textarea,-submit", "y" ], // match IE, not FF.
[ "Text input and text area and a disabled submit, text input focused", "!text,textarea,-submit", "n" ],
[ "Text input and checkbox, text input focused", "!text,checkbox", "y" ],
[ "Text input and radio, text input focused", "!text,radio", "y" ],
[ "Text input and text area, textarea focused", "text,!textarea", "n" ],
@@ -1,14 +1,14 @@
Tests various combinations of form elements and how implicit submission works with them.

Single text input should submit: PASS
Single text input with submit disabled should submit: PASS
Single text input with submit disabled should not submit: PASS
Multiple text inputs should not submit: PASS
Multiple text inputs with submit should submit: PASS
Multiple text inputs with submit disabled should not submit: PASS
Multiple text inputs and multiple submits, first submit disabled should submit: PASS
Multiple text inputs and multiple submits, first submit disabled should not submit: PASS
Text input and text area, text input focused should submit: PASS
Text input and text area and a submit, text input focused should submit: PASS
Text input and text area and a disabled submit, text input focused should submit: PASS
Text input and text area and a disabled submit, text input focused should not submit: PASS
Text input and checkbox, text input focused should submit: PASS
Text input and radio, text input focused should submit: PASS
Text input and text area, textarea focused should not submit: PASS

This file was deleted.

@@ -1,14 +1,14 @@
Tests various combinations of form elements and how implicit submission works with them.

Single text input should submit: PASS
Single text input with submit disabled should submit: PASS
Single text input with submit disabled should not submit: PASS
Multiple text inputs should not submit: PASS
Multiple text inputs with submit should submit: PASS
Multiple text inputs with submit disabled should not submit: PASS
Multiple text inputs and multiple submits, first submit disabled should submit: PASS
Multiple text inputs and multiple submits, first submit disabled should not submit: PASS
Text input and text area, text input focused should submit: PASS
Text input and text area and a submit, text input focused should submit: PASS
Text input and text area and a disabled submit, text input focused should submit: PASS
Text input and text area and a disabled submit, text input focused should not submit: PASS
Text input and checkbox, text input focused should submit: PASS
Text input and radio, text input focused should submit: PASS
Text input and text area, textarea focused should not submit: PASS
@@ -192,7 +192,7 @@ bool HTMLButtonElement::isSuccessfulSubmitButton() const
{
// HTML spec says that buttons must have names to be considered successful.
// However, other browsers do not impose this constraint.
return m_type == SUBMIT && !isDisabledFormControl();
return m_type == SUBMIT;
}

bool HTMLButtonElement::matchesDefaultPseudoClass() const
@@ -884,7 +884,7 @@ bool HTMLInputElement::isSuccessfulSubmitButton() const
{
// HTML spec says that buttons must have names to be considered successful.
// However, other browsers do not impose this constraint. So we do not.
return !isDisabledFormControl() && m_inputType->canBeSuccessfulSubmitButton();
return m_inputType->canBeSuccessfulSubmitButton();
}

bool HTMLInputElement::matchesDefaultPseudoClass() const

0 comments on commit 7f2b47e

Please sign in to comment.