Changeset 286869 in webkit
- Timestamp:
- Dec 10, 2021 12:37:40 PM (7 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 22 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/forms/datetimelocal/ValidityState-typeMismatch-datetimelocal-expected.txt (modified) (2 diffs)
-
LayoutTests/fast/forms/datetimelocal/ValidityState-typeMismatch-datetimelocal.html (modified) (2 diffs)
-
LayoutTests/fast/forms/datetimelocal/datetime-local-value-sanitization-expected.txt (added)
-
LayoutTests/fast/forms/datetimelocal/datetime-local-value-sanitization.html (added)
-
LayoutTests/fast/forms/datetimelocal/input-valueasnumber-datetimelocal-expected.txt (modified) (2 diffs)
-
LayoutTests/fast/forms/datetimelocal/input-valueasnumber-datetimelocal.html (modified) (2 diffs)
-
LayoutTests/fast/forms/time/time-validity-typemismatch-expected.txt (modified) (2 diffs)
-
LayoutTests/fast/forms/time/time-validity-typemismatch.html (modified) (2 diffs)
-
LayoutTests/fast/forms/time/time-valueasdate-expected.txt (modified) (1 diff)
-
LayoutTests/fast/forms/time/time-valueasdate.html (modified) (1 diff)
-
LayoutTests/fast/forms/time/time-valueasnumber-expected.txt (modified) (1 diff)
-
LayoutTests/fast/forms/time/time-valueasnumber.html (modified) (1 diff)
-
LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt (modified) (1 diff)
-
LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/datetime-local-expected.txt (modified) (2 diffs)
-
LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/time-2-expected.txt (modified) (1 diff)
-
LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt (modified) (1 diff)
-
LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/datetime-local-expected.txt (modified) (2 diffs)
-
LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/time-2-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/html/BaseDateAndTimeInputType.h (modified) (1 diff)
-
Source/WebCore/html/DateTimeLocalInputType.cpp (modified) (1 diff)
-
Source/WebCore/html/DateTimeLocalInputType.h (modified) (1 diff)
-
Source/WebCore/platform/DateComponents.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r286866 r286869 1 2021-12-10 Chris Dumez <cdumez@apple.com> 2 3 Improve <type="datetime-local"> value parsing and sanitization 4 https://bugs.webkit.org/show_bug.cgi?id=234039 5 6 Reviewed by Darin Adler. 7 8 * fast/forms/datetimelocal/ValidityState-typeMismatch-datetimelocal-expected.txt: 9 * fast/forms/datetimelocal/ValidityState-typeMismatch-datetimelocal.html: 10 * fast/forms/datetimelocal/input-valueasnumber-datetimelocal-expected.txt: 11 * fast/forms/datetimelocal/input-valueasnumber-datetimelocal.html: 12 Update a couple of existing tests to reflect behavior change. 13 14 * fast/forms/datetimelocal/datetime-local-value-sanitization-expected.txt: Added. 15 * fast/forms/datetimelocal/datetime-local-value-sanitization.html: Added. 16 Improve test coverage for datetime-local value sanitization. 17 18 * platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt: 19 * platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/datetime-local-expected.txt: 20 * platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/time-2-expected.txt: 21 Rebaseline WPT tests now that more checks are passing. 22 1 23 2021-12-10 Gabriel Nava Marino <gnavamarino@apple.com> 2 24 -
trunk/LayoutTests/fast/forms/datetimelocal/ValidityState-typeMismatch-datetimelocal-expected.txt
r103957 r286869 10 10 PASS "2009-09-07T16:49:31.12" is a correct valid datetime-local string. 11 11 PASS "2009-09-07T16:49:31.123" is a correct valid datetime-local string. 12 PASS "2009-09-07T16:49:31.1234567890" is a correct valid datetime-local string.13 12 PASS "275760-09-13T00:00:00.000" is a correct valid datetime-local string. 14 13 PASS "0001-01-01T00:00:00.000" is a correct valid datetime-local string. 14 PASS "2009-09-07 16:49" is a correct valid datetime-local string. 15 15 PASS " 2009-09-07T16:49 " is an invalid datetime-local string and was sanitized. 16 16 PASS "2009-09-07t16:49" is an invalid datetime-local string and was sanitized. 17 PASS "2009-09-07 16:49" is an invalid datetime-local string and was sanitized.18 17 PASS "2009/09/07T16:49" is an invalid datetime-local string and was sanitized. 19 18 PASS "a" is an invalid datetime-local string and was sanitized. … … 21 20 PASS "0000-12-31T23:59:59.999" is an invalid datetime-local string and was sanitized. 22 21 PASS "275760-09-13T00:00:00.001" is an invalid datetime-local string and was sanitized. 22 PASS "2009-09-07T16:49:31.1234567890" is an invalid datetime-local string and was sanitized. 23 23 PASS "invalid" is an invalid datetime-local string and was sanitized while disabled. 24 24 PASS successfullyParsed is true -
trunk/LayoutTests/fast/forms/datetimelocal/ValidityState-typeMismatch-datetimelocal.html
r155268 r286869 46 46 shouldBeValid('2009-09-07T16:49:31.12'); 47 47 shouldBeValid('2009-09-07T16:49:31.123'); 48 shouldBeValid('2009-09-07T16:49:31.1234567890');49 48 shouldBeValid('275760-09-13T00:00:00.000'); 50 49 shouldBeValid('0001-01-01T00:00:00.000'); 50 shouldBeValid('2009-09-07 16:49'); 51 51 52 52 // Invalid values 53 53 shouldBeInvalid(' 2009-09-07T16:49 '); 54 54 shouldBeInvalid('2009-09-07t16:49'); 55 shouldBeInvalid('2009-09-07 16:49');56 55 shouldBeInvalid('2009/09/07T16:49'); 57 56 shouldBeInvalid('a'); … … 59 58 shouldBeInvalid('0000-12-31T23:59:59.999'); 60 59 shouldBeInvalid('275760-09-13T00:00:00.001'); 60 shouldBeInvalid('2009-09-07T16:49:31.1234567890'); 61 61 62 62 // Disabled -
trunk/LayoutTests/fast/forms/datetimelocal/input-valueasnumber-datetimelocal-expected.txt
r219663 r286869 9 9 PASS valueAsNumberFor("2009-12-22T11:32:11") is Date.UTC(2009, 11, 22, 11, 32, 11) 10 10 PASS setValueAsNumberAndGetValue(1969, 11, 1, 0, 0, 0, 0) is "1969-12-01T00:00" 11 PASS setValueAsNumberAndGetValue(1970, 0, 1, 10, 1, 0, 100) is "1970-01-01T10:01:00.1 00"11 PASS setValueAsNumberAndGetValue(1970, 0, 1, 10, 1, 0, 100) is "1970-01-01T10:01:00.1" 12 12 PASS setValueAsNumberAndGetValue(2009, 11, 31, 23, 59, 59, 999) is "2009-12-31T23:59:59.999" 13 13 PASS setValueAsNumberAndGetValue(10000, 0, 1, 12, 0, 1, 0) is "10000-01-01T12:00:01" … … 27 27 PASS input.valueAsNumber = Date.UTC(275760, 8, 13, 0, 0, 0, 1) threw exception NotSupportedError: The operation is not supported.. 28 28 Step attribute value and string representation: 29 PASS input.step = "1"; setValueAsNumberAndGetValue(2010, 0, 21, 0, 0, 0, 0) is "2010-01-21T00:00 :00"30 PASS input.step = "0.001"; setValueAsNumberAndGetValue(2010, 0, 21, 0, 0, 0, 0) is "2010-01-21T00:00 :00.000"29 PASS input.step = "1"; setValueAsNumberAndGetValue(2010, 0, 21, 0, 0, 0, 0) is "2010-01-21T00:00" 30 PASS input.step = "0.001"; setValueAsNumberAndGetValue(2010, 0, 21, 0, 0, 0, 0) is "2010-01-21T00:00" 31 31 PASS successfullyParsed is true 32 32 -
trunk/LayoutTests/fast/forms/datetimelocal/input-valueasnumber-datetimelocal.html
r219663 r286869 33 33 34 34 shouldBe('setValueAsNumberAndGetValue(1969, 11, 1, 0, 0, 0, 0)', '"1969-12-01T00:00"'); 35 shouldBe('setValueAsNumberAndGetValue(1970, 0, 1, 10, 1, 0, 100)', '"1970-01-01T10:01:00.1 00"');35 shouldBe('setValueAsNumberAndGetValue(1970, 0, 1, 10, 1, 0, 100)', '"1970-01-01T10:01:00.1"'); 36 36 shouldBe('setValueAsNumberAndGetValue(2009, 11, 31, 23, 59, 59, 999)', '"2009-12-31T23:59:59.999"'); 37 37 shouldBe('setValueAsNumberAndGetValue(10000, 0, 1, 12, 0, 1, 0)', '"10000-01-01T12:00:01"'); … … 55 55 debug('Step attribute value and string representation:'); 56 56 // If the step attribute value is 1 second and the second part is 0, we should show the second part. 57 shouldBe('input.step = "1"; setValueAsNumberAndGetValue(2010, 0, 21, 0, 0, 0, 0)', '"2010-01-21T00:00 :00"');57 shouldBe('input.step = "1"; setValueAsNumberAndGetValue(2010, 0, 21, 0, 0, 0, 0)', '"2010-01-21T00:00"'); 58 58 // If the step attribute value is 0.001 second and the millisecond part is 0, we should show the millisecond part. 59 shouldBe('input.step = "0.001"; setValueAsNumberAndGetValue(2010, 0, 21, 0, 0, 0, 0)', '"2010-01-21T00:00 :00.000"');59 shouldBe('input.step = "0.001"; setValueAsNumberAndGetValue(2010, 0, 21, 0, 0, 0, 0)', '"2010-01-21T00:00"'); 60 60 </script> 61 61 <script src="../../../resources/js-test-post.js"></script> -
trunk/LayoutTests/fast/forms/time/time-validity-typemismatch-expected.txt
r123836 r286869 11 11 PASS "23:59:59.12" is a correct valid time string. 12 12 PASS "23:59:59.123" is a correct valid time string. 13 PASS "23:59:59.1234567890" is a correct valid time string.14 PASS "00:00:00.0000000000" is a correct valid time string.15 13 PASS " 00:00 " is an invalid time string and was sanitized. 16 14 PASS "1:23" is an invalid time string and was sanitized. … … 34 32 PASS "23:45:06.abc" is an invalid time string and was sanitized. 35 33 PASS "23:45:06.789abc" is an invalid time string and was sanitized. 34 PASS "23:59:59.1234567890" is an invalid time string and was sanitized. 35 PASS "00:00:00.0000000000" is an invalid time string and was sanitized. 36 36 PASS "invalid" is an invalid time string and was sanitized while disabled. 37 37 PASS successfullyParsed is true -
trunk/LayoutTests/fast/forms/time/time-validity-typemismatch.html
r155268 r286869 47 47 shouldBeValid('23:59:59.12'); 48 48 shouldBeValid('23:59:59.123'); 49 shouldBeValid('23:59:59.1234567890');50 shouldBeValid('00:00:00.0000000000');51 49 52 50 // Invalid values … … 72 70 shouldBeInvalid('23:45:06.abc'); 73 71 shouldBeInvalid('23:45:06.789abc'); 72 shouldBeInvalid('23:59:59.1234567890'); 73 shouldBeInvalid('00:00:00.0000000000'); 74 74 75 75 // Disabled -
trunk/LayoutTests/fast/forms/time/time-valueasdate-expected.txt
r123422 r286869 24 24 Step attribute value and string representation: 25 25 PASS input.step = "1"; setValueAsDateAndGetValue(0, 0, 0, 0) is "00:00:00" 26 PASS input.step = "0.001"; setValueAsDateAndGetValue(0, 0, 0, 0) is "00:00:00.0 00"26 PASS input.step = "0.001"; setValueAsDateAndGetValue(0, 0, 0, 0) is "00:00:00.0" 27 27 PASS successfullyParsed is true 28 28 -
trunk/LayoutTests/fast/forms/time/time-valueasdate.html
r155268 r286869 51 51 shouldBe('input.step = "1"; setValueAsDateAndGetValue(0, 0, 0, 0)', '"00:00:00"'); 52 52 // If the step attribute value is 0.001 second and the millisecond part is 0, we should show the millisecond part. 53 shouldBe('input.step = "0.001"; setValueAsDateAndGetValue(0, 0, 0, 0)', '"00:00:00.0 00"');53 shouldBe('input.step = "0.001"; setValueAsDateAndGetValue(0, 0, 0, 0)', '"00:00:00.0"'); 54 54 </script> 55 55 <script src="../../../resources/js-test-post.js"></script> -
trunk/LayoutTests/fast/forms/time/time-valueasnumber-expected.txt
r219663 r286869 27 27 Step attribute value and string representation: 28 28 PASS input.step = "1"; setValueAsNumberAndGetValue(0, 0, 0, 0) is "00:00:00" 29 PASS input.step = "0.001"; setValueAsNumberAndGetValue(0, 0, 0, 0) is "00:00:00.0 00"29 PASS input.step = "0.001"; setValueAsNumberAndGetValue(0, 0, 0, 0) is "00:00:00.0" 30 30 PASS successfullyParsed is true 31 31 -
trunk/LayoutTests/fast/forms/time/time-valueasnumber.html
r219663 r286869 51 51 shouldBe('input.step = "1"; setValueAsNumberAndGetValue(0, 0, 0, 0)', '"00:00:00"'); 52 52 // If the step attribute value is 0.001 second and the millisecond part is 0, we should show the millisecond part. 53 shouldBe('input.step = "0.001"; setValueAsNumberAndGetValue(0, 0, 0, 0)', '"00:00:00.0 00"');53 shouldBe('input.step = "0.001"; setValueAsNumberAndGetValue(0, 0, 0, 0)', '"00:00:00.0"'); 54 54 </script> 55 55 <script src="../../../resources/js-test-post.js"></script> -
trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt
r286855 r286869 20 20 PASS [INPUT in DATETIME-LOCAL status] The required attribute is not set 21 21 PASS [INPUT in DATETIME-LOCAL status] Valid local date and time string(2000-12-10T12:00:00) 22 FAIL [INPUT in DATETIME-LOCAL status] Valid local date and time string(2000-12-10 12:00) assert_false: The validity.valueMissing should be false. expected false got true 22 PASS [INPUT in DATETIME-LOCAL status] Valid local date and time string(2000-12-10 12:00) 23 23 PASS [INPUT in DATETIME-LOCAL status] Valid local date and time string(1979-10-14T12:00:00.001) 24 24 PASS [INPUT in DATETIME-LOCAL status] The value attribute is a number(1234567) 25 25 PASS [INPUT in DATETIME-LOCAL status] The value attribute is a Date object 26 26 PASS [INPUT in DATETIME-LOCAL status] Invalid local date and time string(1979-10-99 99:99) 27 FAIL [INPUT in DATETIME-LOCAL status] Valid local date and time string(1979-10-14 12:00:00) assert_false: The validity.valueMissing should be false. expected false got true 27 PASS [INPUT in DATETIME-LOCAL status] Valid local date and time string(1979-10-14 12:00:00) 28 28 PASS [INPUT in DATETIME-LOCAL status] Invalid local date and time string(2001-12-21 12:00)-two white space 29 29 PASS [INPUT in DATETIME-LOCAL status] the value attribute is a string(abc) -
trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/datetime-local-expected.txt
r267658 r286869 2 2 PASS empty value 3 3 PASS datetime-local input value set to 2014-01-01T11:11:11.111 without min/max 4 FAIL datetime-local input value set to 2014-01-01 11:11:11.111 without min/max assert_equals: expected "2014-01-01T11:11:11.111" but got "" 5 FAIL datetime-local input value set to 2014-01-01 11:11 without min/max assert_equals: expected "2014-01-01T11:11" but got "" 6 FAIL datetime-local input value set to 2014-01-01 00:00:00.000 without min/max assert_equals: expected "2014-01-01T00:00" but got "" 4 PASS datetime-local input value set to 2014-01-01 11:11:11.111 without min/max 5 PASS datetime-local input value set to 2014-01-01 11:11 without min/max 6 PASS datetime-local input value set to 2014-01-01 00:00:00.000 without min/max 7 7 PASS datetime-local input value set to 2014-01-0 11:11 without min/max 8 8 PASS datetime-local input value set to 2014-01-01 11:1 without min/max … … 13 13 PASS invalid datetime-local input value 5 14 14 PASS invalid datetime-local input value 6 15 FAIL Value >= min attribute assert_equals: expected "2014-01-01T11:12" but got "" 16 FAIL Value < min attribute assert_equals: expected "2014-01-01T11:11" but got " "17 FAIL Value <= max attribute assert_equals: expected "2014-01-01T11:10" but got "" 18 FAIL Value > max attribute assert_equals: expected "2014-01-01T11:11" but got " "15 PASS Value >= min attribute 16 FAIL Value < min attribute assert_equals: expected "2014-01-01T11:11" but got "2014-01-01T11:10" 17 PASS Value <= max attribute 18 FAIL Value > max attribute assert_equals: expected "2014-01-01T11:11" but got "2014-01-01T11:12" 19 19 -
trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/time-2-expected.txt
r267658 r286869 6 6 PASS Valid value: value should be 00:00:00.00 7 7 PASS Valid value: value should be 00:00:00.000 8 FAIL Invalid value: fraction should have one, two or three ASCII digits. Value should be empty assert_equals: expected "" but got "00:00:00.0000" 8 PASS Invalid value: fraction should have one, two or three ASCII digits. Value should be empty 9 9 PASS Invalid value: hour should have two ASCII digits. Value should be empty 10 10 PASS Invalid value: minutes should have two ASCII digits. Value should be empty -
trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt
r286855 r286869 20 20 PASS [INPUT in DATETIME-LOCAL status] The required attribute is not set 21 21 PASS [INPUT in DATETIME-LOCAL status] Valid local date and time string(2000-12-10T12:00:00) 22 FAIL [INPUT in DATETIME-LOCAL status] Valid local date and time string(2000-12-10 12:00) assert_false: The validity.valueMissing should be false. expected false got true 22 PASS [INPUT in DATETIME-LOCAL status] Valid local date and time string(2000-12-10 12:00) 23 23 PASS [INPUT in DATETIME-LOCAL status] Valid local date and time string(1979-10-14T12:00:00.001) 24 24 PASS [INPUT in DATETIME-LOCAL status] The value attribute is a number(1234567) 25 25 PASS [INPUT in DATETIME-LOCAL status] The value attribute is a Date object 26 26 PASS [INPUT in DATETIME-LOCAL status] Invalid local date and time string(1979-10-99 99:99) 27 FAIL [INPUT in DATETIME-LOCAL status] Valid local date and time string(1979-10-14 12:00:00) assert_false: The validity.valueMissing should be false. expected false got true 27 PASS [INPUT in DATETIME-LOCAL status] Valid local date and time string(1979-10-14 12:00:00) 28 28 PASS [INPUT in DATETIME-LOCAL status] Invalid local date and time string(2001-12-21 12:00)-two white space 29 29 PASS [INPUT in DATETIME-LOCAL status] the value attribute is a string(abc) -
trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/datetime-local-expected.txt
r267658 r286869 2 2 PASS empty value 3 3 PASS datetime-local input value set to 2014-01-01T11:11:11.111 without min/max 4 FAIL datetime-local input value set to 2014-01-01 11:11:11.111 without min/max assert_equals: expected "2014-01-01T11:11:11.111" but got "" 5 FAIL datetime-local input value set to 2014-01-01 11:11 without min/max assert_equals: expected "2014-01-01T11:11" but got "" 6 FAIL datetime-local input value set to 2014-01-01 00:00:00.000 without min/max assert_equals: expected "2014-01-01T00:00" but got "" 4 PASS datetime-local input value set to 2014-01-01 11:11:11.111 without min/max 5 PASS datetime-local input value set to 2014-01-01 11:11 without min/max 6 PASS datetime-local input value set to 2014-01-01 00:00:00.000 without min/max 7 7 PASS datetime-local input value set to 2014-01-0 11:11 without min/max 8 8 PASS datetime-local input value set to 2014-01-01 11:1 without min/max … … 13 13 PASS invalid datetime-local input value 5 14 14 PASS invalid datetime-local input value 6 15 FAIL Value >= min attribute assert_equals: expected "2014-01-01T11:12" but got "" 16 FAIL Value < min attribute assert_equals: expected "2014-01-01T11:11" but got " "17 FAIL Value <= max attribute assert_equals: expected "2014-01-01T11:10" but got "" 18 FAIL Value > max attribute assert_equals: expected "2014-01-01T11:11" but got " "15 PASS Value >= min attribute 16 FAIL Value < min attribute assert_equals: expected "2014-01-01T11:11" but got "2014-01-01T11:10" 17 PASS Value <= max attribute 18 FAIL Value > max attribute assert_equals: expected "2014-01-01T11:11" but got "2014-01-01T11:12" 19 19 -
trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/time-2-expected.txt
r267658 r286869 6 6 PASS Valid value: value should be 00:00:00.00 7 7 PASS Valid value: value should be 00:00:00.000 8 FAIL Invalid value: fraction should have one, two or three ASCII digits. Value should be empty assert_equals: expected "" but got "00:00:00.0000" 8 PASS Invalid value: fraction should have one, two or three ASCII digits. Value should be empty 9 9 PASS Invalid value: hour should have two ASCII digits. Value should be empty 10 10 PASS Invalid value: minutes should have two ASCII digits. Value should be empty -
trunk/Source/WebCore/ChangeLog
r286868 r286869 1 2021-12-10 Chris Dumez <cdumez@apple.com> 2 3 Improve <type="datetime-local"> value parsing and sanitization 4 https://bugs.webkit.org/show_bug.cgi?id=234039 5 6 Reviewed by Darin Adler. 7 8 Improve <type="datetime-local"> value parsing and sanitization. 9 10 Test: fast/forms/datetimelocal/datetime-local-value-sanitization.html 11 12 * html/BaseDateAndTimeInputType.h: 13 * html/DateTimeLocalInputType.cpp: 14 (WebCore::DateTimeLocalInputType::sanitizeValue const): 15 Implement value sanitization for <type="datetime-local"> so that: 16 - if the input uses a space as date / time separator, the sanitized value will use a 'T' instead. 17 - The output will use the shortest possible string, omitting seconds or milliseconds when 0, as per 18 https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-normalised-local-date-and-time-string 19 20 * html/DateTimeLocalInputType.h: 21 * platform/DateComponents.cpp: 22 (WebCore::DateComponents::parseTime): 23 Fix bug where we would allow more than 3 digits for the millisecond part of the time (we 24 would silently ignore follow-up digits instead of failing parsing). This is as per: 25 - https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-time-string 26 This was covered by one of the subtests in imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/datetime-local.html 27 28 (WebCore::isDateTimeLocalSeparator): 29 (WebCore::DateComponents::parseDateTimeLocal): 30 Allow using a space as date / time separator in <type="datetime-local">, instead of simply allowing a 'T'. 31 This would align our behavior with Gecko and the specification: 32 - https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-local-date-and-time-string 33 Note that Blink still seems to only allow 'T' as separator. 34 35 36 (WebCore::DateComponents::toStringForTime const): 37 The output will use the shortest possible string, omitting seconds or milliseconds when 0, as per 38 https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-normalised-local-date-and-time-string 39 1 40 2021-12-10 Alex Christensen <achristensen@webkit.org> 2 41 -
trunk/Source/WebCore/html/BaseDateAndTimeInputType.h
r286560 r286869 101 101 // InputType functions: 102 102 String visibleValue() const final; 103 String sanitizeValue(const String&) const final;103 String sanitizeValue(const String&) const override; 104 104 void setValue(const String&, bool valueChanged, TextFieldEventBehavior) final; 105 105 WallTime valueAsDate() const override; -
trunk/Source/WebCore/html/DateTimeLocalInputType.cpp
r286560 r286869 100 100 } 101 101 102 String DateTimeLocalInputType::sanitizeValue(const String& proposedValue) const 103 { 104 if (proposedValue.isEmpty()) 105 return proposedValue; 106 107 auto components = DateComponents::fromParsingDateTimeLocal(proposedValue); 108 return components ? components->toString() : emptyString(); 109 } 110 102 111 String DateTimeLocalInputType::formatDateTimeFieldsState(const DateTimeFieldsState& state) const 103 112 { -
trunk/Source/WebCore/html/DateTimeLocalInputType.h
r286560 r286869 53 53 std::optional<DateComponents> parseToDateComponents(StringView) const final; 54 54 std::optional<DateComponents> setMillisecondToDateComponents(double) const final; 55 String sanitizeValue(const String&) const final; 55 56 56 57 bool isValidFormat(OptionSet<DateTimeFormatValidationResults>) const final; -
trunk/Source/WebCore/platform/DateComponents.cpp
r281955 r286869 478 478 millisecond = parseInt(temporaryBuffer, 2); 479 479 *millisecond *= 10; 480 } else { 481 // Regardless of the number of digits, we only ever parse at most 3. All other 482 // digits after that are ignored, but the buffer is incremented as if they were 483 // all parsed. 480 } else if (digitsLength == 3) 484 481 millisecond = parseInt(temporaryBuffer, 3); 485 } 482 else 483 return false; 486 484 487 485 // Due to the countDigits above, the parseInt calls should all be successful. … … 503 501 } 504 502 503 // Gecko allows both 'T' and a space as datetime-local separator (see https://github.com/whatwg/html/issues/2276). 504 // WPT tests also expect this behavior. 505 template<typename CharacterType> static bool isDateTimeLocalSeparator(CharacterType c) 506 { 507 return c == 'T' || c == ' '; 508 } 509 505 510 // https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#local-dates-and-times 506 511 template<typename CharacterType> bool DateComponents::parseDateTimeLocal(StringParsingBuffer<CharacterType>& buffer) … … 509 514 return false; 510 515 511 if (!skipExactly (buffer, 'T'))516 if (!skipExactly<isDateTimeLocalSeparator>(buffer)) 512 517 return false; 513 518 … … 761 766 case SecondFormat::Second: 762 767 return makeString(pad('0', 2, m_hour), ':', pad('0', 2, m_minute), ':', pad('0', 2, m_second)); 763 case SecondFormat::Millisecond: 764 return makeString(pad('0', 2, m_hour), ':', pad('0', 2, m_minute), ':', pad('0', 2, m_second), '.', pad('0', 3, m_millisecond)); 768 case SecondFormat::Millisecond: { 769 auto resultWithoutMilliseconds = makeString(pad('0', 2, m_hour), ':', pad('0', 2, m_minute), ':', pad('0', 2, m_second), '.'); 770 if (!(m_millisecond % 100)) 771 return makeString(resultWithoutMilliseconds, m_millisecond / 100); 772 if (!(m_millisecond % 10)) 773 return makeString(resultWithoutMilliseconds, pad('0', 2, m_millisecond / 10)); 774 return makeString(resultWithoutMilliseconds, pad('0', 3, m_millisecond)); 775 } 765 776 } 766 777 }
Note: See TracChangeset
for help on using the changeset viewer.