Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
<button> and <select> elements with "readonly" attribute shouldn't be…
… barred from constraint validation https://bugs.webkit.org/show_bug.cgi?id=250037 Reviewed by Aditya Keerthi. Per spec, only <input> [1], <textarea> [2], and form-associated custom elements [3] are barred from constraint validation if "readonly" attribute is present. This change makes "readonly" attribute check conditional based on readOnlyBarsFromConstraintValidation(). We can't use supportsReadonly() instead as it reports `false` for certain <input> types, violating the spec [1]. Aligns WebKit with Gecko and the spec. Tests: imported/w3c/web-platform-tests/html/semantics/forms/the-button-element/button-willvalidate-readonly-attribute.html imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/select-willvalidate-readonly-attribute.html [1] https://html.spec.whatwg.org/multipage/input.html#the-readonly-attribute:barred-from-constraint-validation [2] https://html.spec.whatwg.org/multipage/form-elements.html#the-textarea-element:barred-from-constraint-validation [3] https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-core-concepts:barred-from-constraint-validation * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-button-element/button-willvalidate-readonly-attribute-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-button-element/button-willvalidate-readonly-attribute.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/select-willvalidate-readonly-attribute-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/select-willvalidate-readonly-attribute.html: Added. * Source/WebCore/html/HTMLFormControlElement.h * Source/WebCore/html/HTMLFormControlElement.cpp: (WebCore::HTMLFormControlElement::computeWillValidate const): * Source/WebCore/html/HTMLTextFormControlElement.h: Canonical link: https://commits.webkit.org/258485@main
- Loading branch information
Alexey Shvayka
committed
Jan 5, 2023
1 parent
096f188
commit a4eb84d
Showing
7 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
...ml/semantics/forms/the-button-element/button-willvalidate-readonly-attribute-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
1 2 | ||
|
||
PASS Button element with "readonly" attribute shouldn't be barred from constraint validation | ||
|
14 changes: 14 additions & 0 deletions
14
...tests/html/semantics/forms/the-button-element/button-willvalidate-readonly-attribute.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE HTML> | ||
<meta charset="utf-8"> | ||
<title>Button element with "readonly" attribute shouldn't be barred from constraint validation</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<button id="implicitSubmitButton" readonly>1</button> | ||
<button id="explicitSubmitButton" readonly type="submit">2</button> | ||
<script> | ||
test(() => { | ||
assert_true(implicitSubmitButton.willValidate); | ||
assert_true(explicitSubmitButton.willValidate); | ||
}); | ||
</script> |
4 changes: 4 additions & 0 deletions
4
...ml/semantics/forms/the-select-element/select-willvalidate-readonly-attribute-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
|
||
PASS Select element with "readonly" attribute shouldn't be barred from constraint validation | ||
|
24 changes: 24 additions & 0 deletions
24
...tests/html/semantics/forms/the-select-element/select-willvalidate-readonly-attribute.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE HTML> | ||
<meta charset="utf-8"> | ||
<title>Select element with "readonly" attribute shouldn't be barred from constraint validation</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<select id="singleSelect" readonly> | ||
<option>1 | ||
<option>2 | ||
</select> | ||
|
||
<select id="multiSelect" readonly multiple> | ||
<option>a | ||
<option>b | ||
<option>c | ||
<option>d | ||
</select> | ||
|
||
<script> | ||
test(() => { | ||
assert_true(singleSelect.willValidate); | ||
assert_true(multiSelect.willValidate); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters