New issue
Advanced search Search tips

Issue 683041 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner: ----
Closed: Feb 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug



Sign in to add a comment

.value property setter for input[type="time"] should reject values with >3 fractional decimal places

Project Member Reported by cvrebert@google.com, Jan 20 2017

Issue description

Chrome Version: 55.0.2883.95
OS: macOS 10.12.2

What steps will reproduce the problem?
(1) Open http://w3c-test.org/html/semantics/forms/the-input-element/time-2.html in Chrome.
(2) Observe the test results.

What is the actual result?
The following test assertion fails:
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"

What is the expected result?
The test assertion in question should pass.


Further details:
The test in question does the equivalent of:
    anInputOfTypeTime.value = "00:00:00.0000";

The `value` property uses the *value* mode defined in
https://html.spec.whatwg.org/multipage/forms.html#dom-input-value
so:
> On setting, it must set the element's value to the new value,
> [...], invoke the value sanitization algorithm, [...]

Per https://html.spec.whatwg.org/multipage/forms.html#time-state-(type=time):value-sanitization-algorithm
> The value sanitization algorithm is as follows:
> If the value of the element is not a **valid time string**, then set it to the empty string instead.

**Valid time string** is defined in
https://html.spec.whatwg.org/multipage/infrastructure.html#valid-time-string
and the portion regarding fractional seconds says:
> 3. If second is not an integer, or optionally if second is an integer:
>     1. A U+002E FULL STOP character (.)
>     2. One, two, or three ASCII digits, representing the fractional part of second

Thus, the code in question should result in the value getting set to the empty string,
rather than the given value (which has 4 digits after the decimal point).
 

Comment 1 by tkent@chromium.org, Jan 20 2017

Labels: Hotlist-Interop Hotlist-GoodFirstBug
Status: Available (was: Untriaged)
Hello,

This bug is due to DateComponents::parseTime considering fractions with over 3 digits as valid.
https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/DateComponents.cpp?type=cs&l=450

The test passes after adding another condition to return false for digitsLength >= 4.

As far as I understand DateComponents::parseTime is only called by "time-related" input types so we shouldn't have side-effects? - need more input on this.

Thanks,
Matt

Comment 3 by tkent@chromium.org, Feb 6 2017

#2,

Yeah, IFAIK, DateComponents class is used only for date/time input types. Changing DateComponents should be a reasonable fix for this.

Can you please take a look?
https://codereview.chromium.org/2678343007/
Project Member

Comment 5 by bugdroid1@chromium.org, Feb 8 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/925b3122a05d1ecaeedc8780a05089de19a6990a

commit 925b3122a05d1ecaeedc8780a05089de19a6990a
Author: Matthieu.Rigolot <Matthieu.Rigolot@gmail.com>
Date: Wed Feb 08 22:26:02 2017

input[type=time] and input[type=datetime-local] should not accept milliseconds with 4+ digits.

Modify DateComponents::parseTime to reject values with >3 fractional decimal places.
New behavior matches to the specification and Firefox behavor.

https://html.spec.whatwg.org/multipage/infrastructure.html#times

BUG= 683041 

Review-Url: https://codereview.chromium.org/2678343007
Cr-Commit-Position: refs/heads/master@{#449109}

[modify] https://crrev.com/925b3122a05d1ecaeedc8780a05089de19a6990a/AUTHORS
[delete] https://crrev.com/9cb6cef367150495dc15eb0e20525752fe9e198e/third_party/WebKit/LayoutTests/external/wpt/html/semantics/forms/the-input-element/time-2-expected.txt
[modify] https://crrev.com/925b3122a05d1ecaeedc8780a05089de19a6990a/third_party/WebKit/LayoutTests/fast/forms/datetimelocal/ValidityState-typeMismatch-datetimelocal-expected.txt
[modify] https://crrev.com/925b3122a05d1ecaeedc8780a05089de19a6990a/third_party/WebKit/LayoutTests/fast/forms/datetimelocal/ValidityState-typeMismatch-datetimelocal.html
[modify] https://crrev.com/925b3122a05d1ecaeedc8780a05089de19a6990a/third_party/WebKit/LayoutTests/fast/forms/time/time-validity-typemismatch-expected.txt
[modify] https://crrev.com/925b3122a05d1ecaeedc8780a05089de19a6990a/third_party/WebKit/LayoutTests/fast/forms/time/time-validity-typemismatch.html
[modify] https://crrev.com/925b3122a05d1ecaeedc8780a05089de19a6990a/third_party/WebKit/Source/platform/DateComponents.cpp

Comment 6 by tkent@chromium.org, Feb 8 2017

Labels: M-58
Status: Fixed (was: Available)

Sign in to add a comment