diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 8818ec4f76a..199a0ea76db 100644 --- a/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -2475,8 +2475,23 @@ double HTMLInputElement::default_step() const if (type_state() == TypeAttributeState::Time) return 60; - dbgln("HTMLInputElement::default_step() not implemented for input type {}", type()); - return 0; + // https://html.spec.whatwg.org/multipage/input.html#date-state-(type=date):concept-input-step-default + if (type_state() == TypeAttributeState::Date) + return 1; + + // https://html.spec.whatwg.org/multipage/input.html#month-state-(type=month):concept-input-step-default + if (type_state() == TypeAttributeState::Month) + return 1; + + // https://html.spec.whatwg.org/multipage/input.html#week-state-(type=week):concept-input-step-default + if (type_state() == TypeAttributeState::Week) + return 1; + + // https://html.spec.whatwg.org/multipage/input.html#local-date-and-time-state-(type=datetime-local):concept-input-step-default + if (type_state() == TypeAttributeState::LocalDateAndTime) + return 60; + + VERIFY_NOT_REACHED(); } // https://html.spec.whatwg.org/multipage/input.html#concept-input-step-scale @@ -2494,8 +2509,23 @@ double HTMLInputElement::step_scale_factor() const if (type_state() == TypeAttributeState::Time) return 1000; - dbgln("HTMLInputElement::step_scale_factor() not implemented for input type {}", type()); - return 0; + // https://html.spec.whatwg.org/multipage/input.html#date-state-(type=date):concept-input-step-scale + if (type_state() == TypeAttributeState::Date) + return 86400000; + + // https://html.spec.whatwg.org/multipage/input.html#month-state-(type=month):concept-input-step-scale + if (type_state() == TypeAttributeState::Month) + return 1; + + // https://html.spec.whatwg.org/multipage/input.html#week-state-(type=week):concept-input-step-scale + if (type_state() == TypeAttributeState::Week) + return 604800000; + + // https://html.spec.whatwg.org/multipage/input.html#local-date-and-time-state-(type=datetime-local):concept-input-step-scale + if (type_state() == TypeAttributeState::LocalDateAndTime) + return 1000; + + VERIFY_NOT_REACHED(); } // https://html.spec.whatwg.org/multipage/input.html#concept-input-step diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/constraints/form-validation-validity-stepMismatch.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/constraints/form-validation-validity-stepMismatch.txt new file mode 100644 index 00000000000..b26670b0922 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/constraints/form-validation-validity-stepMismatch.txt @@ -0,0 +1,34 @@ +Harness status: OK + +Found 28 tests + +24 Pass +4 Fail +Pass [INPUT in DATE status] The step attribute is not set +Pass [INPUT in DATE status] The value attibute is empty string +Pass [INPUT in DATE status] The value must match the step +Pass [INPUT in DATE status] The value must mismatch the step +Pass [INPUT in MONTH status] The step attribute is not set +Pass [INPUT in MONTH status] The value attibute is empty string +Pass [INPUT in MONTH status] The value must match the step +Pass [INPUT in MONTH status] The value must mismatch the step +Pass [INPUT in WEEK status] The step attribute is not set +Pass [INPUT in WEEK status] The value attibute is empty string +Fail [INPUT in WEEK status] The value must match the step +Fail [INPUT in WEEK status] The value must mismatch the step +Pass [INPUT in TIME status] The step attribute is not set +Pass [INPUT in TIME status] The value attibute is empty string +Pass [INPUT in TIME status] The value must match the step +Pass [INPUT in TIME status] The value must mismatch the step +Pass [INPUT in DATETIME-LOCAL status] The step attribute is not set +Pass [INPUT in DATETIME-LOCAL status] The value attibute is empty string +Pass [INPUT in DATETIME-LOCAL status] The value must match the step +Pass [INPUT in DATETIME-LOCAL status] The value must mismatch the step +Pass [INPUT in NUMBER status] The step attribute is not set +Pass [INPUT in NUMBER status] The step attribute is not set and the value attribute is a floating number +Pass [INPUT in NUMBER status] The value attribute is empty string +Pass [INPUT in NUMBER status] The value must match the step +Pass [INPUT in NUMBER status] The value must mismatch the step +Fail [INPUT in NUMBER status] No step mismatch when step is a floating number and value is its integral multiple +Fail [INPUT in NUMBER status] No step mismatch when step is a floating number in exponent format and value is its integral multiple +Pass [INPUT in NUMBER status] Step mismatch when step is a very small floating number and value is not its integral multiple \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/the-input-element/input-stepdown-weekmonth.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/the-input-element/input-stepdown-weekmonth.txt new file mode 100644 index 00000000000..f693e278ecf --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/the-input-element/input-stepdown-weekmonth.txt @@ -0,0 +1,7 @@ +Harness status: OK + +Found 2 tests + +2 Pass +Pass Calling stepDown() on input - month - where value < min should not modify value. +Pass Calling stepDown() on input - week - where value < min should not modify value. \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/the-input-element/input-stepdown.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/the-input-element/input-stepdown.txt new file mode 100644 index 00000000000..79aea5478fe --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/the-input-element/input-stepdown.txt @@ -0,0 +1,10 @@ +Harness status: OK + +Found 5 tests + +5 Pass +Pass Forms +Pass Calling stepDown() on input - number - where value < min should not modify value. +Pass Calling stepDown() on input - date - where value < min should not modify value. +Pass Calling stepDown() on input - datetime-local - where value < min should not modify value. +Pass Calling stepDown() on input - time - where value < min should not modify value. \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/the-input-element/input-stepup-weekmonth.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/the-input-element/input-stepup-weekmonth.txt new file mode 100644 index 00000000000..7a128deef02 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/the-input-element/input-stepup-weekmonth.txt @@ -0,0 +1,7 @@ +Harness status: OK + +Found 2 tests + +2 Pass +Pass Calling stepUp() on input -month- where value > max should not modify value. +Pass Calling stepUp() on input -week- where value > max should not modify value. \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/the-input-element/input-stepup.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/the-input-element/input-stepup.txt new file mode 100644 index 00000000000..ea00ce5a56f --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/the-input-element/input-stepup.txt @@ -0,0 +1,10 @@ +Harness status: OK + +Found 5 tests + +5 Pass +Pass Forms +Pass Calling stepUp() on input -number- where value > max should not modify value. +Pass Calling stepUp() on input -date- where value > max should not modify value. +Pass Calling stepUp() on input -datetime-local- where value > max should not modify value. +Pass Calling stepUp() on input -time- where value > max should not modify value. \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/the-input-element/month.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/the-input-element/month.txt new file mode 100644 index 00000000000..9cab370c9b1 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/the-input-element/month.txt @@ -0,0 +1,21 @@ +Harness status: OK + +Found 15 tests + +14 Pass +1 Fail +Pass year can be more than four digits +Pass valid value test +Pass year can contain prefixes of zero, as long as there are at least four digits +Pass month type support on input element +Pass User agents must not allow the user to set the value to a non-empty string that is not a valid month string. +Pass Month value can be empty string. +Pass When value attribute has two digits year value, the value,which is invalid, must return empty string. +Pass When value is set with invalid value, the value must return empty string. +Pass When step attribute is given invalid value, it must ignore the invalid value and use defaul value instead. +Pass Month should be <= 13: If the value of the element is not a valid month string, then set it to the empty string instead. +Pass Month should be > 0: If the value of the element is not a valid month string, then set it to the empty string instead.> +Fail Year should be > 0: If the value of the element is not a valid year string, then set it to the empty string instead.> +Pass Month should be two digits: If the value of the element is not a valid month string, then set it to the empty string instead.> +Pass Month should be two digits not characters: If the value of the element is not a valid month string, then set it to the empty string instead.> +Pass Value should be two parts: If the value of the element is not a valid month string, then set it to the empty string instead.> \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/forms/constraints/form-validation-validity-stepMismatch.html b/Tests/LibWeb/Text/input/wpt-import/html/semantics/forms/constraints/form-validation-validity-stepMismatch.html new file mode 100644 index 00000000000..4eb19a9b54e --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/forms/constraints/form-validation-validity-stepMismatch.html @@ -0,0 +1,81 @@ + + +