RESOLVED FIXED 76893
Implement value sanitization algorithm for type=datetime
https://bugs.webkit.org/show_bug.cgi?id=76893
Summary Implement value sanitization algorithm for type=datetime
Kent Tamura
Reported 2012-01-23 20:46:02 PST
http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#date-and-time-state-(type=datetime) > The value sanitization algorithm is as follows: If the value of the element is a valid global date and time string, then adjust the time so that the value represents the same point in time but expressed in the UTC time zone as a valid normalized forced-UTC global date and time string, otherwise, set it to the empty string instead.
Attachments
Patch (18.28 KB, patch)
2012-10-18 19:31 PDT, Kunihiko Sakamoto
no flags
Patch 2 (18.56 KB, patch)
2012-10-18 21:16 PDT, Kunihiko Sakamoto
no flags
Kunihiko Sakamoto
Comment 1 2012-10-18 19:31:53 PDT
Kent Tamura
Comment 2 2012-10-18 20:28:48 PDT
Comment on attachment 169537 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=169537&action=review > LayoutTests/fast/forms/datetime/datetime-value-sanitization-expected.txt:9 > +PASS input.value = "2009-09-07T16:49:00Z"; input.value is "2009-09-07T16:49Z" > +PASS input.value = "2009-09-07T16:49:00.000Z"; input.value is "2009-09-07T16:49Z" Can you preserve trailing zeros of the input datetime values? If we do so, we should do: - Add "SecondFormat m_preferredSecondForamt;" and "SecondFormat preferredSecondFormat() const" to DateComponents - m_preferredSecondFormat is updated in DateComponents::parseTime - DateTimeInputType::sanitizeValue calls date.toString(date.preferredSecondFormat) > LayoutTests/fast/forms/datetime/datetime-value-sanitization.html:1 > +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <!DOCTYPE html> is enough. > LayoutTests/fast/forms/datetime/datetime-value-sanitization.html:8 > +<p id="description"></p> > +<div id="console"></div> Please remove them. They are unnecessary nowadays. > LayoutTests/fast/forms/datetime/datetime-value-sanitization.html:15 > +// Valid values Such labels are useful for test results too. So please print it by debug('Valid values'); > LayoutTests/fast/forms/datetime/datetime-value-sanitization.html:16 > +shouldBe('input.value = "2009-09-07T16:49Z"; input.value', '"2009-09-07T16:49Z"'); should be: shouldBeEqualToString('input.value ...', '2009-09-07T16:49Z'); to avoid ugly nested quotes.
Kunihiko Sakamoto
Comment 3 2012-10-18 20:49:53 PDT
Comment on attachment 169537 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=169537&action=review >> LayoutTests/fast/forms/datetime/datetime-value-sanitization-expected.txt:9 >> +PASS input.value = "2009-09-07T16:49:00.000Z"; input.value is "2009-09-07T16:49Z" > > Can you preserve trailing zeros of the input datetime values? > > If we do so, we should do: > - Add "SecondFormat m_preferredSecondForamt;" and "SecondFormat preferredSecondFormat() const" to DateComponents > - m_preferredSecondFormat is updated in DateComponents::parseTime > - DateTimeInputType::sanitizeValue calls date.toString(date.preferredSecondFormat) The spec says that normalized value is the shortest possible representation of the given time. http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#valid-normalized-forced-utc-global-date-and-time-string Is there a good reason for keeping the second format of the input?
Kent Tamura
Comment 4 2012-10-18 20:56:18 PDT
Comment on attachment 169537 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=169537&action=review >>> LayoutTests/fast/forms/datetime/datetime-value-sanitization-expected.txt:9 >>> +PASS input.value = "2009-09-07T16:49:00.000Z"; input.value is "2009-09-07T16:49Z" >> >> Can you preserve trailing zeros of the input datetime values? >> >> If we do so, we should do: >> - Add "SecondFormat m_preferredSecondForamt;" and "SecondFormat preferredSecondFormat() const" to DateComponents >> - m_preferredSecondFormat is updated in DateComponents::parseTime >> - DateTimeInputType::sanitizeValue calls date.toString(date.preferredSecondFormat) > > The spec says that normalized value is the shortest possible representation of the given time. > http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#valid-normalized-forced-utc-global-date-and-time-string > Is there a good reason for keeping the second format of the input? Oh, I see. It is a standard behavior. So, the C++ part of your patch is ok.
Kunihiko Sakamoto
Comment 5 2012-10-18 21:16:23 PDT
Kunihiko Sakamoto
Comment 6 2012-10-18 21:17:14 PDT
Updated the test. Please take another look.
Kent Tamura
Comment 7 2012-10-18 21:40:36 PDT
Comment on attachment 169541 [details] Patch 2 ok
WebKit Review Bot
Comment 8 2012-10-18 21:45:53 PDT
Comment on attachment 169541 [details] Patch 2 Clearing flags on attachment: 169541 Committed r131853: <http://trac.webkit.org/changeset/131853>
WebKit Review Bot
Comment 9 2012-10-18 21:45:57 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.