Skip to content

Test validity.rangeOverflow and stepMismatch for input type=range - #65927

Open
sb3nder wants to merge 1 commit into
web-platform-tests:masterfrom
sb3nder:form-constraint-2
Open

sb3nder wants to merge 1 commit into
web-platform-tests:masterfrom
sb3nder:form-constraint-2

Conversation

@sb3nder

@sb3nder sb3nder commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Tests that validity.rangeOverflow of a input type=range is true when the value is greater that max;
and that validity.stepMismatch is true when the value is not an integral multiple of step.
Also:

  • Test :in-range/:out-of-range and :valid/:invalid pseudo-classes.
  • Test willValidate for missing input types: number, image, range, checkbox, radio.

Also:
- Test :in-range/:out-of-range and :valid/:invalid.
- Test willValidate for missing input types.
@sb3nder
sb3nder marked this pull request as ready for review November 30, 2026 21:42
hjanuschka added a commit to hjanuschka/WebKit that referenced this pull request Dec 5, 2026
https://bugs.webkit.org/show_bug.cgi?id=334543

Reviewed by NOBODY (OOPS!).

Per the Range state value sanitization algorithm, the user agent only
clamps an overflowing value to the maximum "if the maximum is not less
than the minimum". A reversed range (e.g. <input type=range min=200>,
where the maximum defaults to 100) is deliberately left suffering from
an overflow: validity.rangeOverflow must be true, the control must
match :invalid and :out-of-range, and form submission must be blocked.
The "has a reversed range" carve-out requires a periodic domain and
only applies to type=time.

WebKit raised the parsed maximum up to the minimum in
RangeInputType::createStepRange, making the control report itself as
valid. Firefox implements the spec behavior and Chromium is working
towards it.

Keep the parsed maximum, and instead pin values to the minimum in
StepRange::clampValue when the range is reversed and the type is not
reversible, so the sanitized value is unchanged from the previous
behavior (and identical to Firefox) in every case - only the validity
flags change. Reversible time ranges (min=23:00 max=01:00) are
unaffected. proportionFromValue returns 0 for a reversed range so the
slider thumb stays pinned to the start, and keyboard stepping is a
no-op since no valid value exists to step to.

Sync the constraint-validation and pseudo-class WPTs with
web-platform-tests/wpt#65927, which covers reversed ranges for
type=range. The three new FAIL baselines in the willValidate and
valid-invalid tests are a separate pre-existing divergence (WebKit
bars <input type=image> from constraint validation; the spec does
not) that the refreshed tests now cover.

* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeOverflow-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeOverflow.html:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeUnderflow-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeUnderflow.html:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-stepMismatch-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-stepMismatch.html:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid.html:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-willValidate-datalist-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-willValidate-datalist.html:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-willValidate-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-willValidate.html:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/selectors/pseudo-classes/inrange-outofrange-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/selectors/pseudo-classes/inrange-outofrange.html:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/selectors/pseudo-classes/utils.js:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/selectors/pseudo-classes/valid-invalid-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/selectors/pseudo-classes/valid-invalid.html:
* Source/WebCore/html/RangeInputType.cpp:
(WebCore::RangeInputType::createStepRange):
(WebCore::RangeInputType::handleKeydownEvent):
(WebCore::ensureMaximum): Deleted.
* Source/WebCore/html/StepRange.cpp:
(WebCore::StepRange::clampValue):
* Source/WebCore/html/StepRange.h:
(WebCore::StepRange::proportionFromValue):
hjanuschka added a commit to hjanuschka/WebKit that referenced this pull request Dec 5, 2026
https://bugs.webkit.org/show_bug.cgi?id=334544

Reviewed by NOBODY (OOPS!).

Per the Range state value sanitization algorithm, the user agent only
clamps an overflowing value to the maximum "if the maximum is not less
than the minimum". A reversed range (e.g. <input type=range min=200>,
where the maximum defaults to 100) is deliberately left suffering from
an overflow: validity.rangeOverflow must be true, the control must
match :invalid and :out-of-range, and form submission must be blocked.
The "has a reversed range" carve-out requires a periodic domain and
only applies to type=time.

WebKit raised the parsed maximum up to the minimum in
RangeInputType::createStepRange, making the control report itself as
valid. Firefox implements the spec behavior and Chromium is working
towards it.

Keep the parsed maximum, and instead pin values to the minimum in
StepRange::clampValue when the range is reversed and the type is not
reversible, so the sanitized value is unchanged from the previous
behavior (and identical to Firefox) in every case - only the validity
flags change. Reversible time ranges (min=23:00 max=01:00) are
unaffected. proportionFromValue returns 0 for a reversed range so the
slider thumb stays pinned to the start, and keyboard stepping is a
no-op since no valid value exists to step to.

Sync the constraint-validation and pseudo-class WPTs with
web-platform-tests/wpt#65927, which covers reversed ranges for
type=range. The three new FAIL baselines in the willValidate and
valid-invalid tests are a separate pre-existing divergence (WebKit
bars <input type=image> from constraint validation; the spec does
not) that the refreshed tests now cover.

* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeOverflow-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeOverflow.html:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeUnderflow-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-rangeUnderflow.html:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-stepMismatch-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-stepMismatch.html:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid.html:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-willValidate-datalist-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-willValidate-datalist.html:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-willValidate-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-willValidate.html:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/selectors/pseudo-classes/inrange-outofrange-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/selectors/pseudo-classes/inrange-outofrange.html:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/selectors/pseudo-classes/utils.js:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/selectors/pseudo-classes/valid-invalid-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/selectors/pseudo-classes/valid-invalid.html:
* Source/WebCore/html/RangeInputType.cpp:
(WebCore::RangeInputType::createStepRange):
(WebCore::RangeInputType::handleKeydownEvent):
(WebCore::ensureMaximum): Deleted.
* Source/WebCore/html/StepRange.cpp:
(WebCore::StepRange::clampValue):
* Source/WebCore/html/StepRange.h:
(WebCore::StepRange::proportionFromValue):

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants