diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 552cab2a37c..93de597f58f 100644 --- a/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -2422,10 +2422,10 @@ double HTMLInputElement::step_base() const // 2. If the element has a value content attribute, and the result of applying the algorithm to convert a string to a number to the value of // the value content attribute is not an error, then return that result. - // AD-HOC: https://github.com/whatwg/html/issues/11097 Skipping this step seems to be necessary in order to get the - // behavior that's actually expected — and necessary in order get the tests to pass (they otherwise fail). - // if (auto value = convert_string_to_number(this->value()); value.has_value()) - // return *value; + if (auto value = get_attribute(HTML::AttributeNames::value); value.has_value()) { + if (auto value_as_number = convert_string_to_number(value.value()); value_as_number.has_value()) + return value_as_number.value(); + } // 3. If a default step base is defined for this element given its type attribute's state, then return it. if (type_state() == TypeAttributeState::Week) { diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/constraints/form-validation-checkValidity.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/constraints/form-validation-checkValidity.txt index ec3e29e01ba..ff3d68261cc 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/constraints/form-validation-checkValidity.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/constraints/form-validation-checkValidity.txt @@ -1,8 +1,8 @@ Harness status: OK -Found 130 tests +Found 132 tests -116 Pass +118 Pass 14 Fail Pass [INPUT in TEXT status] no constraint Pass [INPUT in TEXT status] no constraint (in a form) @@ -112,6 +112,8 @@ Fail [INPUT in NUMBER status] suffering from an underflow Fail [INPUT in NUMBER status] suffering from an underflow (in a form) Pass [INPUT in NUMBER status] suffering from a step mismatch Pass [INPUT in NUMBER status] suffering from a step mismatch (in a form) +Pass [INPUT in NUMBER status] (with 'value' content attribute) suffering from a step mismatch +Pass [INPUT in NUMBER status] (with 'value' content attribute) suffering from a step mismatch (in a form) Pass [INPUT in NUMBER status] suffering from being missing Pass [INPUT in NUMBER status] suffering from being missing (in a form) Pass [INPUT in CHECKBOX status] no constraint diff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/forms/constraints/form-validation-checkValidity.html b/Tests/LibWeb/Text/input/wpt-import/html/semantics/forms/constraints/form-validation-checkValidity.html index b312614b094..f7013e21642 100644 --- a/Tests/LibWeb/Text/input/wpt-import/html/semantics/forms/constraints/form-validation-checkValidity.html +++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/forms/constraints/form-validation-checkValidity.html @@ -104,6 +104,7 @@ {conditions: {max: "5", value: "6"}, expected: false, name: "[target] suffering from an overflow"}, {conditions: {min: "5", value: "4"}, expected: false, name: "[target] suffering from an underflow"}, {conditions: {step: 2 * 1 * 1, value: "3"}, expected: false, name: "[target] suffering from a step mismatch"}, + {conditions: {step: 10, value: "20", content_value: "9"}, expected: false, name: "[target] (with 'value' content attribute) suffering from a step mismatch"}, {conditions: {required: true, value: ""}, expected: false, name: "[target] suffering from being missing"} ] }, diff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/forms/constraints/support/validator.js b/Tests/LibWeb/Text/input/wpt-import/html/semantics/forms/constraints/support/validator.js index aa43b3a2f6a..9cc9e684d5f 100644 --- a/Tests/LibWeb/Text/input/wpt-import/html/semantics/forms/constraints/support/validator.js +++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/forms/constraints/support/validator.js @@ -340,6 +340,8 @@ var validator = { for (var attr in obj) { if (attr === "message") ctl.setCustomValidity(obj[attr]); + else if (attr === "content_value") + ctl.setAttribute("value", obj["content_value"]) else if (attr === "checked" || obj[attr] || obj[attr] === "") ctl[attr] = obj[attr]; }