Changeset 103957 in webkit


Ignore:
Timestamp:
Jan 3, 2012 12:21:44 PM (12 years ago)
Author:
Joseph Pecoraro
Message:

<http://webkit.org/b/59951> Implement Date and Time Input Value Sanitization

Source/WebCore:

Sanitize non-parsable incoming strings to the empty string.

Reviewed by Kent Tamura.

Covered by existing tests.

  • html/BaseDateAndTimeInputType.h:
  • html/BaseDateAndTimeInputType.cpp:

(WebCore::BaseDateAndTimeInputType::sanitizeValue): check if the
incoming string is valid. If not just return the empty string.

LayoutTests:

Update ValidityState typeMismatch tests for date types, since
setting an invalid value now sanitized to the empty string.
So, what used to be an invalid value with a typeMismatch is
now a valid empty string and there is never a typeMismatch.

  • for rangeOverflow / rangeUnderflow tests update the test to point out when a value was sanitized.
  • for typeMismatch tests, typeMismatch can no longer happen for sanitized values. Change the test to output if the value was sanitized or not and ensure that we are never in a typeMismatch state. Disabled inputs are also sanitized when their value changes.

Reviewed by Kent Tamura.

  • fast/forms/date/ValidityState-rangeOverflow-date-expected.txt:
  • fast/forms/date/ValidityState-rangeOverflow-date.html:
  • fast/forms/date/ValidityState-rangeUnderflow-date-expected.txt:
  • fast/forms/date/ValidityState-rangeUnderflow-date.html:
  • fast/forms/date/ValidityState-typeMismatch-date-expected.txt:
  • fast/forms/date/ValidityState-typeMismatch-date.html:
  • fast/forms/datetime/ValidityState-rangeOverflow-datetime-expected.txt:
  • fast/forms/datetime/ValidityState-rangeOverflow-datetime.html:
  • fast/forms/datetime/ValidityState-rangeUnderflow-datetime-expected.txt:
  • fast/forms/datetime/ValidityState-rangeUnderflow-datetime.html:
  • fast/forms/datetime/ValidityState-typeMismatch-datetime-expected.txt:
  • fast/forms/datetime/ValidityState-typeMismatch-datetime.html:
  • fast/forms/datetimelocal/ValidityState-rangeOverflow-datetimelocal-expected.txt:
  • fast/forms/datetimelocal/ValidityState-rangeOverflow-datetimelocal.html:
  • fast/forms/datetimelocal/ValidityState-rangeUnderflow-datetimelocal-expected.txt:
  • fast/forms/datetimelocal/ValidityState-rangeUnderflow-datetimelocal.html:
  • fast/forms/datetimelocal/ValidityState-typeMismatch-datetimelocal-expected.txt:
  • fast/forms/datetimelocal/ValidityState-typeMismatch-datetimelocal.html:
  • fast/forms/month/ValidityState-rangeOverflow-month-expected.txt:
  • fast/forms/month/ValidityState-rangeOverflow-month.html:
  • fast/forms/month/ValidityState-rangeUnderflow-month-expected.txt:
  • fast/forms/month/ValidityState-rangeUnderflow-month.html:
  • fast/forms/month/ValidityState-typeMismatch-month-expected.txt:
  • fast/forms/month/ValidityState-typeMismatch-month.html:
  • fast/forms/time/ValidityState-rangeOverflow-time-expected.txt:
  • fast/forms/time/ValidityState-rangeOverflow-time.html:
  • fast/forms/time/ValidityState-rangeUnderflow-time-expected.txt:
  • fast/forms/time/ValidityState-rangeUnderflow-time.html:
  • fast/forms/time/ValidityState-typeMismatch-time-expected.txt:
  • fast/forms/time/ValidityState-typeMismatch-time.html:
  • fast/forms/week/ValidityState-rangeOverflow-week-expected.txt:
  • fast/forms/week/ValidityState-rangeOverflow-week.html:
  • fast/forms/week/ValidityState-rangeUnderflow-week-expected.txt:
  • fast/forms/week/ValidityState-rangeUnderflow-week.html:
  • fast/forms/week/ValidityState-typeMismatch-week-expected.txt:
  • fast/forms/week/ValidityState-typeMismatch-week.html:
Location:
trunk
Files:
40 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r103953 r103957  
     12011-12-22  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Implement Date and Time Input Value Sanitization
     4        https://bugs.webkit.org/show_bug.cgi?id=59951
     5
     6        Update ValidityState typeMismatch tests for date types, since
     7        setting an invalid value now sanitized to the empty string.
     8        So, what used to be an invalid value with a typeMismatch is
     9        now a valid empty string and there is never a typeMismatch.
     10
     11          - for rangeOverflow / rangeUnderflow tests update the
     12            test to point out when a value was sanitized.
     13          - for typeMismatch tests, typeMismatch can no longer
     14            happen for sanitized values. Change the test to output
     15            if the value was sanitized or not and ensure that
     16            we are never in a typeMismatch state. Disabled inputs
     17            are also sanitized when their value changes.
     18
     19        Reviewed by Kent Tamura.
     20
     21        * fast/forms/date/ValidityState-rangeOverflow-date-expected.txt:
     22        * fast/forms/date/ValidityState-rangeOverflow-date.html:
     23        * fast/forms/date/ValidityState-rangeUnderflow-date-expected.txt:
     24        * fast/forms/date/ValidityState-rangeUnderflow-date.html:
     25        * fast/forms/date/ValidityState-typeMismatch-date-expected.txt:
     26        * fast/forms/date/ValidityState-typeMismatch-date.html:
     27        * fast/forms/datetime/ValidityState-rangeOverflow-datetime-expected.txt:
     28        * fast/forms/datetime/ValidityState-rangeOverflow-datetime.html:
     29        * fast/forms/datetime/ValidityState-rangeUnderflow-datetime-expected.txt:
     30        * fast/forms/datetime/ValidityState-rangeUnderflow-datetime.html:
     31        * fast/forms/datetime/ValidityState-typeMismatch-datetime-expected.txt:
     32        * fast/forms/datetime/ValidityState-typeMismatch-datetime.html:
     33        * fast/forms/datetimelocal/ValidityState-rangeOverflow-datetimelocal-expected.txt:
     34        * fast/forms/datetimelocal/ValidityState-rangeOverflow-datetimelocal.html:
     35        * fast/forms/datetimelocal/ValidityState-rangeUnderflow-datetimelocal-expected.txt:
     36        * fast/forms/datetimelocal/ValidityState-rangeUnderflow-datetimelocal.html:
     37        * fast/forms/datetimelocal/ValidityState-typeMismatch-datetimelocal-expected.txt:
     38        * fast/forms/datetimelocal/ValidityState-typeMismatch-datetimelocal.html:
     39        * fast/forms/month/ValidityState-rangeOverflow-month-expected.txt:
     40        * fast/forms/month/ValidityState-rangeOverflow-month.html:
     41        * fast/forms/month/ValidityState-rangeUnderflow-month-expected.txt:
     42        * fast/forms/month/ValidityState-rangeUnderflow-month.html:
     43        * fast/forms/month/ValidityState-typeMismatch-month-expected.txt:
     44        * fast/forms/month/ValidityState-typeMismatch-month.html:
     45        * fast/forms/time/ValidityState-rangeOverflow-time-expected.txt:
     46        * fast/forms/time/ValidityState-rangeOverflow-time.html:
     47        * fast/forms/time/ValidityState-rangeUnderflow-time-expected.txt:
     48        * fast/forms/time/ValidityState-rangeUnderflow-time.html:
     49        * fast/forms/time/ValidityState-typeMismatch-time-expected.txt:
     50        * fast/forms/time/ValidityState-typeMismatch-time.html:
     51        * fast/forms/week/ValidityState-rangeOverflow-week-expected.txt:
     52        * fast/forms/week/ValidityState-rangeOverflow-week.html:
     53        * fast/forms/week/ValidityState-rangeUnderflow-week-expected.txt:
     54        * fast/forms/week/ValidityState-rangeUnderflow-week.html:
     55        * fast/forms/week/ValidityState-typeMismatch-week-expected.txt:
     56        * fast/forms/week/ValidityState-typeMismatch-week.html:
     57
    1582012-01-03  Alexis Menard  <alexis.menard@openbossa.org>
    259
  • trunk/LayoutTests/fast/forms/date/ValidityState-rangeOverflow-date-expected.txt

    r92819 r103957  
    1010PASS The value "2010-01-27" doesn't overflow the maximum value "2010-01-28".
    1111PASS The value "2010-01-27" doesn't overflow the maximum value "2011-01-26".
    12 PASS The value "foo" doesn't overflow the maximum value "2011-01-26".
     12PASS The value "" sanitized from "foo" doesn't overflow the maximum value "2011-01-26".
    1313PASS The value "2010-01-27" doesn't overflow the maximum value "0000-01-01".
    1414PASS The value "2010-01-27" overflows the maximum value "2010-01-26".
  • trunk/LayoutTests/fast/forms/date/ValidityState-rangeOverflow-date.html

    r98407 r103957  
    2727}
    2828
    29 function checkNotOverflow(value, max, disabled)
     29function checkNotOverflow(value, max, disabled, sanitized)
    3030{
    3131    input.value = value;
     
    3434    var overflow = input.validity.rangeOverflow;
    3535    var resultText = 'The value "' + input.value + '" ' +
     36        (sanitized ? 'sanitized from "' + value + '" ' : '') +
    3637        (overflow ? 'overflows' : 'doesn\'t overflow') +
    3738        ' the maximum value "' + input.max + '"' + (disabled ? ' when disabled.' : '.');
     
    4041    else
    4142        testPassed(resultText);
     43}
     44
     45function checkSanitizedValueNotOverflow(value, max, disabled)
     46{
     47    // For date types, invalid values are sanitized to "".
     48    checkNotOverflow(value, max, disabled, true);
    4249}
    4350
     
    5158checkNotOverflow('2010-01-27', '2010-01-28');
    5259checkNotOverflow('2010-01-27', '2011-01-26');
    53 checkNotOverflow('foo', '2011-01-26');
     60checkSanitizedValueNotOverflow('foo', '2011-01-26');
    5461checkNotOverflow('2010-01-27', '0000-01-01'); // Too small max value.
    5562
  • trunk/LayoutTests/fast/forms/date/ValidityState-rangeUnderflow-date-expected.txt

    r92819 r103957  
    1111PASS The value "2010-01-27" doesn't underflow the minimum value "2010-01-26".
    1212PASS The value "2010-01-27" doesn't underflow the minimum value "2009-01-28".
    13 PASS The value "foo" doesn't underflow the minimum value "2011-01-26".
     13PASS The value "" sanitized from "foo" doesn't underflow the minimum value "2011-01-26".
    1414PASS The value "2010-01-27" undeflows the minimum value "2010-01-28".
    1515PASS The value "9999-01-01" undeflows the minimum value "10000-12-31".
  • trunk/LayoutTests/fast/forms/date/ValidityState-rangeUnderflow-date.html

    r98407 r103957  
    2727}
    2828
    29 function checkNotUnderflow(value, min, disabled)
     29function checkNotUnderflow(value, min, disabled, sanitized)
    3030{
    3131    input.value = value;
     
    3434    var underflow = input.validity.rangeUnderflow;
    3535    var resultText = 'The value "' + input.value + '" ' +
     36        (sanitized ? 'sanitized from "' + value + '" ' : '') +
    3637        (underflow ? 'underflows' : 'doesn\'t underflow') +
    3738        ' the minimum value "' + input.min + '"' + (disabled ? ' when disabled.' : '.');
     
    4041    else
    4142        testPassed(resultText);
     43}
     44
     45function checkSanitizedValueNotUnderflow(value, max, disabled)
     46{
     47    // For date types, invalid values are sanitized to "".
     48    checkNotUnderflow(value, max, disabled, true);
    4249}
    4350
     
    5461checkNotUnderflow('2010-01-27', '2010-01-26');
    5562checkNotUnderflow('2010-01-27', '2009-01-28');
    56 checkNotUnderflow('foo', '2011-01-26');
     63checkSanitizedValueNotUnderflow('foo', '2011-01-26');
    5764
    5865// Underflow cases
  • trunk/LayoutTests/fast/forms/date/ValidityState-typeMismatch-date-expected.txt

    r92819 r103957  
    2424PASS "2008-02-29" is a correct valid date string.
    2525PASS "2000-02-29" is a correct valid date string.
    26 PASS " 2009-09-07 " is a correct invalid date string.
    27 PASS "a" is a correct invalid date string.
    28 PASS "-1-09-07" is a correct invalid date string.
    29 PASS "0000-12-31" is a correct invalid date string.
    30 PASS "0000-01-01" is a correct invalid date string.
    31 PASS "275760-09-14" is a correct invalid date string.
    32 PASS "2147483648-12-31" is a correct invalid date string.
    33 PASS "2009/09/07" is a correct invalid date string.
    34 PASS "20090907" is a correct invalid date string.
    35 PASS "2009--2-07" is a correct invalid date string.
    36 PASS "2009-00-07" is a correct invalid date string.
    37 PASS "2009-13-07" is a correct invalid date string.
    38 PASS "2009-xx-30" is a correct invalid date string.
    39 PASS "2009-01-32" is a correct invalid date string.
    40 PASS "2009-02-29" is a correct invalid date string.
    41 PASS "2009-03-32" is a correct invalid date string.
    42 PASS "2009-04-31" is a correct invalid date string.
    43 PASS "2009-05-32" is a correct invalid date string.
    44 PASS "2009-06-31" is a correct invalid date string.
    45 PASS "2009-07-32" is a correct invalid date string.
    46 PASS "2009-08-32" is a correct invalid date string.
    47 PASS "2009-09-31" is a correct invalid date string.
    48 PASS "2009-10-32" is a correct invalid date string.
    49 PASS "2009-11-31" is a correct invalid date string.
    50 PASS "2009-12-32" is a correct invalid date string.
    51 PASS "2100-02-29" is a correct invalid date string.
    52 PASS "2009-09-00" is a correct invalid date string.
    53 PASS "2009-09-" is a correct invalid date string.
    54 PASS "2009-09-7" is a correct invalid date string.
    55 PASS "2009-09-001" is a correct invalid date string.
    56 PASS "2009-09-xx" is a correct invalid date string.
    57 PASS "2009-09" is a correct invalid date string.
    58 PASS "2009" is a correct invalid date string.
    59 PASS "2009-09" is a correct valid date string when disabled.
     26PASS " 2009-09-07 " is an invalid date string and was sanitized.
     27PASS "a" is an invalid date string and was sanitized.
     28PASS "-1-09-07" is an invalid date string and was sanitized.
     29PASS "0000-12-31" is an invalid date string and was sanitized.
     30PASS "0000-01-01" is an invalid date string and was sanitized.
     31PASS "275760-09-14" is an invalid date string and was sanitized.
     32PASS "2147483648-12-31" is an invalid date string and was sanitized.
     33PASS "2009/09/07" is an invalid date string and was sanitized.
     34PASS "20090907" is an invalid date string and was sanitized.
     35PASS "2009--2-07" is an invalid date string and was sanitized.
     36PASS "2009-00-07" is an invalid date string and was sanitized.
     37PASS "2009-13-07" is an invalid date string and was sanitized.
     38PASS "2009-xx-30" is an invalid date string and was sanitized.
     39PASS "2009-01-32" is an invalid date string and was sanitized.
     40PASS "2009-02-29" is an invalid date string and was sanitized.
     41PASS "2009-03-32" is an invalid date string and was sanitized.
     42PASS "2009-04-31" is an invalid date string and was sanitized.
     43PASS "2009-05-32" is an invalid date string and was sanitized.
     44PASS "2009-06-31" is an invalid date string and was sanitized.
     45PASS "2009-07-32" is an invalid date string and was sanitized.
     46PASS "2009-08-32" is an invalid date string and was sanitized.
     47PASS "2009-09-31" is an invalid date string and was sanitized.
     48PASS "2009-10-32" is an invalid date string and was sanitized.
     49PASS "2009-11-31" is an invalid date string and was sanitized.
     50PASS "2009-12-32" is an invalid date string and was sanitized.
     51PASS "2100-02-29" is an invalid date string and was sanitized.
     52PASS "2009-09-00" is an invalid date string and was sanitized.
     53PASS "2009-09-" is an invalid date string and was sanitized.
     54PASS "2009-09-7" is an invalid date string and was sanitized.
     55PASS "2009-09-001" is an invalid date string and was sanitized.
     56PASS "2009-09-xx" is an invalid date string and was sanitized.
     57PASS "2009-09" is an invalid date string and was sanitized.
     58PASS "2009" is an invalid date string and was sanitized.
     59PASS "2009-09" is an invalid date string and was sanitized while disabled.
    6060PASS successfullyParsed is true
    6161
  • trunk/LayoutTests/fast/forms/date/ValidityState-typeMismatch-date.html

    r98407 r103957  
    1212i.type = 'date';
    1313
    14 function check(value, mismatchExpected, disabled)
     14function check(value, disabled)
    1515{
    1616    i.value = value;
    1717    i.disabled = !!disabled;
    18     var actual = i.validity.typeMismatch;
    19     var didPass = actual == mismatchExpected;
    20     var resultText = '"' + value + '" is ' + (didPass ? 'a correct ' : 'an incorrect ') + (actual ? 'invalid' : 'valid') + ' date string' + (disabled ? ' when disabled.' : '.');
    21     if (didPass)
    22         testPassed(resultText);
    23     else
    24         testFailed(resultText);
     18
     19    if (i.validity.typeMismatch)
     20        testFailed('"' + value + '" had typeMismatch. This should not happen with sanitization.');
    2521}
    2622
    27 function shouldBeValid(value, disabled)
     23function shouldBeValid(value)
    2824{
    29     check(value, false, disabled);
     25    check(value);
     26    if ((value === '' && i.value === '') || (value !== '' && i.value !== ""))
     27        testPassed('"' + value + '" is a correct valid date string.');
     28    else
     29        testFailed('"' + value + '" is a valid date string that failed to be set on the input.');
    3030}
    3131
    32 function shouldBeInvalid(value)
     32function shouldBeInvalid(value, disabled)
    3333{
    34     check(value, true);
     34    check(value, disabled);
     35    if (i.value === '')
     36        testPassed('"' + value + '" is an invalid date string and was sanitized' + (disabled ? ' while disabled' : '') + '.');
     37    else
     38        testFailed('"' + value + '" is an invalid date string and was not sanitized' + (disabled ? ' while disabled' : '') + '.');
    3539}
    3640
     
    9397
    9498// Disabled
    95 shouldBeValid('2009-09', true);
     99shouldBeInvalid('2009-09', true);
    96100</script>
    97101<script src="../../js/resources/js-test-post.js"></script>
  • trunk/LayoutTests/fast/forms/datetime/ValidityState-rangeOverflow-datetime-expected.txt

    r92762 r103957  
    1010PASS The value "2010-01-27T12:34Z" doesn't overflow the maximum value "2010-01-27T12:34:56Z".
    1111PASS The value "2010-01-27T12:34Z" doesn't overflow the maximum value "2011-01-26T12:34Z".
    12 PASS The value "foo" doesn't overflow the maximum value "2011-01-26T12:34Z".
     12PASS The value "" sanitized from "foo" doesn't overflow the maximum value "2011-01-26T12:34Z".
    1313PASS The value "2010-01-27T12:34Z" doesn't overflow the maximum value "0000-01-01T00:00Z".
    1414PASS The value "2010-01-27T12:34Z" overflows the maximum value "2010-01-26T12:33:59.999Z".
  • trunk/LayoutTests/fast/forms/datetime/ValidityState-rangeOverflow-datetime.html

    r98407 r103957  
    2727}
    2828
    29 function checkNotOverflow(value, max, disabled)
     29function checkNotOverflow(value, max, disabled, sanitized)
    3030{
    3131    input.value = value;
     
    3434    var overflow = input.validity.rangeOverflow;
    3535    var resultText = 'The value "' + input.value + '" ' +
     36        (sanitized ? 'sanitized from "' + value + '" ' : '') +
    3637        (overflow ? 'overflows' : 'doesn\'t overflow') +
    3738        ' the maximum value "' + input.max + '"' + (disabled ? ' when disabled.' : '.');
     
    4041    else
    4142        testPassed(resultText);
     43}
     44
     45function checkSanitizedValueNotOverflow(value, max, disabled)
     46{
     47    // For date types, invalid values are sanitized to "".
     48    checkNotOverflow(value, max, disabled, true);
    4249}
    4350
     
    5158checkNotOverflow('2010-01-27T12:34Z', '2010-01-27T12:34:56Z');
    5259checkNotOverflow('2010-01-27T12:34Z', '2011-01-26T12:34Z');
    53 checkNotOverflow('foo', '2011-01-26T12:34Z');
     60checkSanitizedValueNotOverflow('foo', '2011-01-26T12:34Z');
    5461checkNotOverflow('2010-01-27T12:34Z', '0000-01-01T00:00Z'); // Too small max value.
    5562
  • trunk/LayoutTests/fast/forms/datetime/ValidityState-rangeUnderflow-datetime-expected.txt

    r92762 r103957  
    1111PASS The value "2010-01-27T12:34Z" doesn't underflow the minimum value "2010-01-26T00:00Z".
    1212PASS The value "2010-01-27T12:34Z" doesn't underflow the minimum value "2009-01-28T00:00Z".
    13 PASS The value "foo" doesn't underflow the minimum value "2011-01-26T00:00Z".
     13PASS The value "" sanitized from "foo" doesn't underflow the minimum value "2011-01-26T00:00Z".
    1414PASS The value "2010-01-27T12:34Z" undeflows the minimum value "2010-01-27T13:00Z".
    1515PASS The value "9999-01-01T12:00Z" undeflows the minimum value "10000-12-31T12:00Z".
  • trunk/LayoutTests/fast/forms/datetime/ValidityState-rangeUnderflow-datetime.html

    r98407 r103957  
    2727}
    2828
    29 function checkNotUnderflow(value, min, disabled)
     29function checkNotUnderflow(value, min, disabled, sanitized)
    3030{
    3131    input.value = value;
     
    3434    var underflow = input.validity.rangeUnderflow;
    3535    var resultText = 'The value "' + input.value + '" ' +
     36        (sanitized ? 'sanitized from "' + value + '" ' : '') +
    3637        (underflow ? 'underflows' : 'doesn\'t underflow') +
    3738        ' the minimum value "' + input.min + '"' + (disabled ? ' when disabled.' : '.');
     
    4041    else
    4142        testPassed(resultText);
     43}
     44
     45function checkSanitizedValueNotUnderflow(value, max, disabled)
     46{
     47    // For date types, invalid values are sanitized to "".
     48    checkNotUnderflow(value, max, disabled, true);
    4249}
    4350
     
    5461checkNotUnderflow('2010-01-27T12:34Z', '2010-01-26T00:00Z');
    5562checkNotUnderflow('2010-01-27T12:34Z', '2009-01-28T00:00Z');
    56 checkNotUnderflow('foo', '2011-01-26T00:00Z');
     63checkSanitizedValueNotUnderflow('foo', '2011-01-26T00:00Z');
    5764
    5865// Underflow cases
  • trunk/LayoutTests/fast/forms/datetime/ValidityState-typeMismatch-datetime-expected.txt

    r92762 r103957  
    1717PASS "0001-01-01T01:30+01:30" is a correct valid datetime string.
    1818PASS "0001-01-01T00:00+01:00" is a correct valid datetime string.
    19 PASS " 2009-09-07T16:49Z " is a correct invalid datetime string.
    20 PASS "2009-09-07T16:49z" is a correct invalid datetime string.
    21 PASS "2009-09-07t16:49Z" is a correct invalid datetime string.
    22 PASS "2009-09-07T16:49" is a correct invalid datetime string.
    23 PASS "2009/09/07T16:49Z" is a correct invalid datetime string.
    24 PASS "a" is a correct invalid datetime string.
    25 PASS "-1-09-07T16:49Z" is a correct invalid datetime string.
    26 PASS "2009-09-07T16:49+23" is a correct invalid datetime string.
    27 PASS "2009-09-07T16:49+23:" is a correct invalid datetime string.
    28 PASS "2009-09-07T16:49+24:00" is a correct invalid datetime string.
    29 PASS "2009-09-07T16:49+23:60" is a correct invalid datetime string.
    30 PASS "2009-09-07T16:49-23" is a correct invalid datetime string.
    31 PASS "2009-09-07T16:49-23:" is a correct invalid datetime string.
    32 PASS "2009-09-07T16:49-24:00" is a correct invalid datetime string.
    33 PASS "2009-09-07T16:49-23:60" is a correct invalid datetime string.
    34 PASS "0000-12-31T23:59:59Z" is a correct invalid datetime string.
    35 PASS "2147483647-12-31T23:59-00:01" is a correct invalid datetime string.
    36 PASS "2147483648-01-01T00:00:00Z" is a correct invalid datetime string.
    37 PASS "invalid" is a correct valid datetime string when disabled.
     19PASS " 2009-09-07T16:49Z " is an invalid datetime string and was sanitized.
     20PASS "2009-09-07T16:49z" is an invalid datetime string and was sanitized.
     21PASS "2009-09-07t16:49Z" is an invalid datetime string and was sanitized.
     22PASS "2009-09-07T16:49" is an invalid datetime string and was sanitized.
     23PASS "2009/09/07T16:49Z" is an invalid datetime string and was sanitized.
     24PASS "a" is an invalid datetime string and was sanitized.
     25PASS "-1-09-07T16:49Z" is an invalid datetime string and was sanitized.
     26PASS "2009-09-07T16:49+23" is an invalid datetime string and was sanitized.
     27PASS "2009-09-07T16:49+23:" is an invalid datetime string and was sanitized.
     28PASS "2009-09-07T16:49+24:00" is an invalid datetime string and was sanitized.
     29PASS "2009-09-07T16:49+23:60" is an invalid datetime string and was sanitized.
     30PASS "2009-09-07T16:49-23" is an invalid datetime string and was sanitized.
     31PASS "2009-09-07T16:49-23:" is an invalid datetime string and was sanitized.
     32PASS "2009-09-07T16:49-24:00" is an invalid datetime string and was sanitized.
     33PASS "2009-09-07T16:49-23:60" is an invalid datetime string and was sanitized.
     34PASS "0000-12-31T23:59:59Z" is an invalid datetime string and was sanitized.
     35PASS "2147483647-12-31T23:59-00:01" is an invalid datetime string and was sanitized.
     36PASS "2147483648-01-01T00:00:00Z" is an invalid datetime string and was sanitized.
     37PASS "invalid" is an invalid datetime string and was sanitized while disabled.
    3838PASS successfullyParsed is true
    3939
  • trunk/LayoutTests/fast/forms/datetime/ValidityState-typeMismatch-datetime.html

    r98407 r103957  
    1212i.type = 'datetime';
    1313
    14 function check(value, mismatchExpected, disabled)
     14function check(value, disabled)
    1515{
    1616    i.value = value;
    1717    i.disabled = !!disabled;
    18     var actual = i.validity.typeMismatch;
    19     var didPass = actual == mismatchExpected;
    20     var resultText = '"' + value + '" is ' + (didPass ? 'a correct ' : 'an incorrect ') + (actual ? 'invalid' : 'valid') + ' datetime string' + (disabled ? ' when disabled.' : '.');
    21     if (didPass)
    22         testPassed(resultText);
    23     else
    24         testFailed(resultText);
     18
     19    if (i.validity.typeMismatch)
     20        testFailed('"' + value + '" had typeMismatch. This should not happen with sanitization.');
    2521}
    2622
    27 function shouldBeValid(value, disabled)
     23function shouldBeValid(value)
    2824{
    29     check(value, false, disabled);
     25    check(value);
     26    if ((value === '' && i.value === '') || (value !== '' && i.value !== ""))
     27        testPassed('"' + value + '" is a correct valid datetime string.');
     28    else
     29        testFailed('"' + value + '" is a valid datetime string that failed to be set on the input.');
    3030}
    3131
    32 function shouldBeInvalid(value)
     32function shouldBeInvalid(value, disabled)
    3333{
    34     check(value, true);
     34    check(value, disabled);
     35    if (i.value === '')
     36        testPassed('"' + value + '" is an invalid datetime string and was sanitized' + (disabled ? ' while disabled' : '') + '.');
     37    else
     38        testFailed('"' + value + '" is an invalid datetime string and was not sanitized' + (disabled ? ' while disabled' : '') + '.');
    3539}
    3640
     
    7175
    7276// Disabled
    73 shouldBeValid('invalid', true);
     77shouldBeInvalid('invalid', true);
    7478</script>
    7579<script src="../../js/resources/js-test-post.js"></script>
  • trunk/LayoutTests/fast/forms/datetimelocal/ValidityState-rangeOverflow-datetimelocal-expected.txt

    r92754 r103957  
    1010PASS The value "2010-01-27T12:34" doesn't overflow the maximum value "2010-01-27T12:34:56".
    1111PASS The value "2010-01-27T12:34" doesn't overflow the maximum value "2011-01-26T12:34".
    12 PASS The value "foo" doesn't overflow the maximum value "2011-01-26T12:34".
     12PASS The value "" sanitized from "foo" doesn't overflow the maximum value "2011-01-26T12:34".
    1313PASS The value "2010-01-27T12:34" doesn't overflow the maximum value "0000-01-01T00:00".
    1414PASS The value "2010-01-27T12:34" overflows the maximum value "2010-01-26T12:33:59.999".
  • trunk/LayoutTests/fast/forms/datetimelocal/ValidityState-rangeOverflow-datetimelocal.html

    r98407 r103957  
    2727}
    2828
    29 function checkNotOverflow(value, max, disabled)
     29function checkNotOverflow(value, max, disabled, sanitized)
    3030{
    3131    input.value = value;
     
    3434    var overflow = input.validity.rangeOverflow;
    3535    var resultText = 'The value "' + input.value + '" ' +
     36        (sanitized ? 'sanitized from "' + value + '" ' : '') +
    3637        (overflow ? 'overflows' : 'doesn\'t overflow') +
    3738        ' the maximum value "' + input.max + '"' + (disabled ? ' when disabled.' : '.');
     
    4041    else
    4142        testPassed(resultText);
     43}
     44
     45function checkSanitizedValueNotOverflow(value, max, disabled)
     46{
     47    // For date types, invalid values are sanitized to "".
     48    checkNotOverflow(value, max, disabled, true);
    4249}
    4350
     
    5158checkNotOverflow('2010-01-27T12:34', '2010-01-27T12:34:56');
    5259checkNotOverflow('2010-01-27T12:34', '2011-01-26T12:34');
    53 checkNotOverflow('foo', '2011-01-26T12:34');
     60checkSanitizedValueNotOverflow('foo', '2011-01-26T12:34');
    5461checkNotOverflow('2010-01-27T12:34', '0000-01-01T00:00'); // Too small max value.
    5562
  • trunk/LayoutTests/fast/forms/datetimelocal/ValidityState-rangeUnderflow-datetimelocal-expected.txt

    r92754 r103957  
    1111PASS The value "2010-01-27T12:34" doesn't underflow the minimum value "2010-01-26T00:00".
    1212PASS The value "2010-01-27T12:34" doesn't underflow the minimum value "2009-01-28T00:00".
    13 PASS The value "foo" doesn't underflow the minimum value "2011-01-26T00:00".
     13PASS The value "" sanitized from "foo" doesn't underflow the minimum value "2011-01-26T00:00".
    1414PASS The value "2010-01-27T12:34" undeflows the minimum value "2010-01-27T13:00".
    1515PASS The value "9999-01-01T12:00" undeflows the minimum value "10000-12-31T12:00".
  • trunk/LayoutTests/fast/forms/datetimelocal/ValidityState-rangeUnderflow-datetimelocal.html

    r98407 r103957  
    2727}
    2828
    29 function checkNotUnderflow(value, min, disabled)
     29function checkNotUnderflow(value, min, disabled, sanitized)
    3030{
    3131    input.value = value;
     
    3434    var underflow = input.validity.rangeUnderflow;
    3535    var resultText = 'The value "' + input.value + '" ' +
     36        (sanitized ? 'sanitized from "' + value + '" ' : '') +
    3637        (underflow ? 'underflows' : 'doesn\'t underflow') +
    3738        ' the minimum value "' + input.min + '"' + (disabled ? ' when disabled.' : '.');
     
    4041    else
    4142        testPassed(resultText);
     43}
     44
     45function checkSanitizedValueNotUnderflow(value, max, disabled)
     46{
     47    // For date types, invalid values are sanitized to "".
     48    checkNotUnderflow(value, max, disabled, true);
    4249}
    4350
     
    5461checkNotUnderflow('2010-01-27T12:34', '2010-01-26T00:00');
    5562checkNotUnderflow('2010-01-27T12:34', '2009-01-28T00:00');
    56 checkNotUnderflow('foo', '2011-01-26T00:00');
     63checkSanitizedValueNotUnderflow('foo', '2011-01-26T00:00');
    5764
    5865// Underflow cases
  • trunk/LayoutTests/fast/forms/datetimelocal/ValidityState-typeMismatch-datetimelocal-expected.txt

    r92754 r103957  
    1313PASS "275760-09-13T00:00:00.000" is a correct valid datetime-local string.
    1414PASS "0001-01-01T00:00:00.000" is a correct valid datetime-local string.
    15 PASS " 2009-09-07T16:49 " is a correct invalid datetime-local string.
    16 PASS "2009-09-07t16:49" is a correct invalid datetime-local string.
    17 PASS "2009-09-07 16:49" is a correct invalid datetime-local string.
    18 PASS "2009/09/07T16:49" is a correct invalid datetime-local string.
    19 PASS "a" is a correct invalid datetime-local string.
    20 PASS "-1-09-07T16:49" is a correct invalid datetime-local string.
    21 PASS "0000-12-31T23:59:59.999" is a correct invalid datetime-local string.
    22 PASS "275760-09-13T00:00:00.001" is a correct invalid datetime-local string.
    23 PASS "invalid" is a correct valid datetime-local string when disabled.
     15PASS " 2009-09-07T16:49 " is an invalid datetime-local string and was sanitized.
     16PASS "2009-09-07t16:49" is an invalid datetime-local string and was sanitized.
     17PASS "2009-09-07 16:49" is an invalid datetime-local string and was sanitized.
     18PASS "2009/09/07T16:49" is an invalid datetime-local string and was sanitized.
     19PASS "a" is an invalid datetime-local string and was sanitized.
     20PASS "-1-09-07T16:49" is an invalid datetime-local string and was sanitized.
     21PASS "0000-12-31T23:59:59.999" is an invalid datetime-local string and was sanitized.
     22PASS "275760-09-13T00:00:00.001" is an invalid datetime-local string and was sanitized.
     23PASS "invalid" is an invalid datetime-local string and was sanitized while disabled.
    2424PASS successfullyParsed is true
    2525
  • trunk/LayoutTests/fast/forms/datetimelocal/ValidityState-typeMismatch-datetimelocal.html

    r98407 r103957  
    1212i.type = 'datetime-local';
    1313
    14 function check(value, mismatchExpected, disabled)
     14function check(value, disabled)
    1515{
    1616    i.value = value;
    1717    i.disabled = !!disabled;
    18     var actual = i.validity.typeMismatch;
    19     var didPass = actual == mismatchExpected;
    20     var resultText = '"' + value + '" is ' + (didPass ? 'a correct ' : 'an incorrect ') + (actual ? 'invalid' : 'valid') + ' datetime-local string' + (disabled ? ' when disabled.' : '.');
    21     if (didPass)
    22         testPassed(resultText);
    23     else
    24         testFailed(resultText);
     18
     19    if (i.validity.typeMismatch)
     20        testFailed('"' + value + '" had typeMismatch. This should not happen with sanitization.');
    2521}
    2622
    27 function shouldBeValid(value, disabled)
     23function shouldBeValid(value)
    2824{
    29     check(value, false, disabled);
     25    check(value);
     26    if ((value === '' && i.value === '') || (value !== '' && i.value !== ""))
     27        testPassed('"' + value + '" is a correct valid datetime-local string.');
     28    else
     29        testFailed('"' + value + '" is a valid datetime-local string that failed to be set on the input.');
    3030}
    3131
    32 function shouldBeInvalid(value)
     32function shouldBeInvalid(value, disabled)
    3333{
    34     check(value, true);
     34    check(value, disabled);
     35    if (i.value === '')
     36        testPassed('"' + value + '" is an invalid datetime-local string and was sanitized' + (disabled ? ' while disabled' : '') + '.');
     37    else
     38        testFailed('"' + value + '" is an invalid datetime-local string and was not sanitized' + (disabled ? ' while disabled' : '') + '.');
    3539}
    3640
     
    5761
    5862// Disabled
    59 shouldBeValid('invalid', true);
     63shouldBeInvalid('invalid', true);
    6064</script>
    6165<script src="../../js/resources/js-test-post.js"></script>
  • trunk/LayoutTests/fast/forms/month/ValidityState-rangeOverflow-month-expected.txt

    r92728 r103957  
    1010PASS The value "2010-01" doesn't overflow the maximum value "2010-02".
    1111PASS The value "2010-01" doesn't overflow the maximum value "2011-01".
    12 PASS The value "foo" doesn't overflow the maximum value "2011-01".
     12PASS The value "" sanitized from "foo" doesn't overflow the maximum value "2011-01".
    1313PASS The value "2010-01" doesn't overflow the maximum value "0000-01".
    1414PASS The value "2010-01" overflows the maximum value "2009-12".
  • trunk/LayoutTests/fast/forms/month/ValidityState-rangeOverflow-month.html

    r98407 r103957  
    2727}
    2828
    29 function checkNotOverflow(value, max, disabled)
     29function checkNotOverflow(value, max, disabled, sanitized)
    3030{
    3131    input.value = value;
     
    3434    var overflow = input.validity.rangeOverflow;
    3535    var resultText = 'The value "' + input.value + '" ' +
     36        (sanitized ? 'sanitized from "' + value + '" ' : '') +
    3637        (overflow ? 'overflows' : 'doesn\'t overflow') +
    3738        ' the maximum value "' + input.max + '"' + (disabled ? ' when disabled.' : '.');
     
    4041    else
    4142        testPassed(resultText);
     43}
     44
     45function checkSanitizedValueNotOverflow(value, max, disabled)
     46{
     47    // For date types, invalid values are sanitized to "".
     48    checkNotOverflow(value, max, disabled, true);
    4249}
    4350
     
    5158checkNotOverflow('2010-01', '2010-02');
    5259checkNotOverflow('2010-01', '2011-01');
    53 checkNotOverflow('foo', '2011-01');
     60checkSanitizedValueNotOverflow('foo', '2011-01');
    5461checkNotOverflow('2010-01', '0000-01'); // Too small max value.
    5562
  • trunk/LayoutTests/fast/forms/month/ValidityState-rangeUnderflow-month-expected.txt

    r92728 r103957  
    1111PASS The value "2010-01" doesn't underflow the minimum value "2009-12".
    1212PASS The value "2010-01" doesn't underflow the minimum value "2009-01".
    13 PASS The value "foo" doesn't underflow the minimum value "2011-01".
     13PASS The value "" sanitized from "foo" doesn't underflow the minimum value "2011-01".
    1414PASS The value "2010-01" undeflows the minimum value "2010-02".
    1515PASS The value "9999-01" undeflows the minimum value "10000-12".
  • trunk/LayoutTests/fast/forms/month/ValidityState-rangeUnderflow-month.html

    r98407 r103957  
    2727}
    2828
    29 function checkNotUnderflow(value, min, disabled)
     29function checkNotUnderflow(value, min, disabled, sanitized)
    3030{
    3131    input.value = value;
     
    3434    var underflow = input.validity.rangeUnderflow;
    3535    var resultText = 'The value "' + input.value + '" ' +
     36        (sanitized ? 'sanitized from "' + value + '" ' : '') +
    3637        (underflow ? 'underflows' : 'doesn\'t underflow') +
    3738        ' the minimum value "' + input.min + '"' + (disabled ? ' when disabled.' : '.');
     
    4041    else
    4142        testPassed(resultText);
     43}
     44
     45function checkSanitizedValueNotUnderflow(value, max, disabled)
     46{
     47    // For date types, invalid values are sanitized to "".
     48    checkNotUnderflow(value, max, disabled, true);
    4249}
    4350
     
    5461checkNotUnderflow('2010-01', '2009-12');
    5562checkNotUnderflow('2010-01', '2009-01');
    56 checkNotUnderflow('foo', '2011-01');
     63checkSanitizedValueNotUnderflow('foo', '2011-01');
    5764
    5865// Underflow cases
  • trunk/LayoutTests/fast/forms/month/ValidityState-typeMismatch-month-expected.txt

    r92728 r103957  
    2020PASS "2009-11" is a correct valid month string.
    2121PASS "2009-12" is a correct valid month string.
    22 PASS " 2009-09 " is a correct invalid month string.
    23 PASS "a" is a correct invalid month string.
    24 PASS "-1-09" is a correct invalid month string.
    25 PASS "0000-12" is a correct invalid month string.
    26 PASS "2147483648-12" is a correct invalid month string.
    27 PASS "275760-10" is a correct invalid month string.
    28 PASS "2009/09" is a correct invalid month string.
    29 PASS "200909" is a correct invalid month string.
    30 PASS "2009--2" is a correct invalid month string.
    31 PASS "2009-00" is a correct invalid month string.
    32 PASS "2009-13" is a correct invalid month string.
    33 PASS "2009-" is a correct invalid month string.
    34 PASS "2009-9" is a correct invalid month string.
    35 PASS "2009-009" is a correct invalid month string.
    36 PASS "2009-xx" is a correct invalid month string.
    37 PASS "2009" is a correct invalid month string.
    38 PASS "invalid" is a correct valid month string when disabled.
     22PASS " 2009-09 " is an invalid month string and was sanitized.
     23PASS "a" is an invalid month string and was sanitized.
     24PASS "-1-09" is an invalid month string and was sanitized.
     25PASS "0000-12" is an invalid month string and was sanitized.
     26PASS "2147483648-12" is an invalid month string and was sanitized.
     27PASS "275760-10" is an invalid month string and was sanitized.
     28PASS "2009/09" is an invalid month string and was sanitized.
     29PASS "200909" is an invalid month string and was sanitized.
     30PASS "2009--2" is an invalid month string and was sanitized.
     31PASS "2009-00" is an invalid month string and was sanitized.
     32PASS "2009-13" is an invalid month string and was sanitized.
     33PASS "2009-" is an invalid month string and was sanitized.
     34PASS "2009-9" is an invalid month string and was sanitized.
     35PASS "2009-009" is an invalid month string and was sanitized.
     36PASS "2009-xx" is an invalid month string and was sanitized.
     37PASS "2009" is an invalid month string and was sanitized.
     38PASS "invalid" is an invalid month string and was sanitized while disabled.
    3939PASS successfullyParsed is true
    4040
  • trunk/LayoutTests/fast/forms/month/ValidityState-typeMismatch-month.html

    r98407 r103957  
    1212i.type = 'month';
    1313
    14 function check(value, mismatchExpected, disabled)
     14function check(value, disabled)
    1515{
    1616    i.value = value;
    1717    i.disabled = !!disabled;
    18     var actual = i.validity.typeMismatch;
    19     var didPass = actual == mismatchExpected;
    20     var resultText = '"' + value + '" is ' + (didPass ? 'a correct ' : 'an incorrect ') + (actual ? 'invalid' : 'valid') + ' month string' + (disabled ? ' when disabled.' : '.');
    21     if (didPass)
    22         testPassed(resultText);
    23     else
    24         testFailed(resultText);
     18
     19    if (i.validity.typeMismatch)
     20        testFailed('"' + value + '" had typeMismatch. This should not happen with sanitization.');
    2521}
    2622
    27 function shouldBeValid(value, disabled)
     23function shouldBeValid(value)
    2824{
    29     check(value, false, disabled);
     25    check(value);
     26    if ((value === '' && i.value === '') || (value !== '' && i.value !== ""))
     27        testPassed('"' + value + '" is a correct valid month string.');
     28    else
     29        testFailed('"' + value + '" is a valid month string that failed to be set on the input.');
    3030}
    3131
    32 function shouldBeInvalid(value)
     32function shouldBeInvalid(value, disabled)
    3333{
    34     check(value, true);
     34    check(value, disabled);
     35    if (i.value === '')
     36        testPassed('"' + value + '" is an invalid month string and was sanitized' + (disabled ? ' while disabled' : '') + '.');
     37    else
     38        testFailed('"' + value + '" is an invalid month string and was not sanitized' + (disabled ? ' while disabled' : '') + '.');
    3539}
    3640
     
    7276
    7377// Disabled
    74 shouldBeValid('invalid', true);
     78shouldBeInvalid('invalid', true);
    7579</script>
    7680<script src="../../js/resources/js-test-post.js"></script>
  • trunk/LayoutTests/fast/forms/time/ValidityState-rangeOverflow-time-expected.txt

    r92746 r103957  
    1010PASS The value "13:16" doesn't overflow the maximum value "13:17".
    1111PASS The value "13:16" doesn't overflow the maximum value "14:15".
    12 PASS The value "foo" doesn't overflow the maximum value "13:16".
     12PASS The value "" sanitized from "foo" doesn't overflow the maximum value "13:16".
    1313PASS The value "13:16" overflows the maximum value "13:15".
    1414PASS The value "23:59:59.999" overflows the maximum value "13:16".
  • trunk/LayoutTests/fast/forms/time/ValidityState-rangeOverflow-time.html

    r98407 r103957  
    2727}
    2828
    29 function checkNotOverflow(value, max, disabled)
     29function checkNotOverflow(value, max, disabled, sanitized)
    3030{
    3131    input.value = value;
     
    3434    var overflow = input.validity.rangeOverflow;
    3535    var resultText = 'The value "' + input.value + '" ' +
     36        (sanitized ? 'sanitized from "' + value + '" ' : '') +
    3637        (overflow ? 'overflows' : 'doesn\'t overflow') +
    3738        ' the maximum value "' + input.max + '"' + (disabled ? ' when disabled.' : '.');
     
    4041    else
    4142        testPassed(resultText);
     43}
     44
     45function checkSanitizedValueNotOverflow(value, max, disabled)
     46{
     47    // For date types, invalid values are sanitized to "".
     48    checkNotOverflow(value, max, disabled, true);
    4249}
    4350
     
    5158checkNotOverflow('13:16', '13:17');
    5259checkNotOverflow('13:16', '14:15');
    53 checkNotOverflow('foo', '13:16');
     60checkSanitizedValueNotOverflow('foo', '13:16');
    5461
    5562// Overflow cases
  • trunk/LayoutTests/fast/forms/time/ValidityState-rangeUnderflow-time-expected.txt

    r92746 r103957  
    1111PASS The value "13:16" doesn't underflow the minimum value "11:00".
    1212PASS The value "13:16" doesn't underflow the minimum value "13:16".
    13 PASS The value "foo" doesn't underflow the minimum value "11:00".
     13PASS The value "" sanitized from "foo" doesn't underflow the minimum value "11:00".
    1414PASS The value "13:16" undeflows the minimum value "13:17".
    1515PASS The value "23:59" undeflows the minimum value "23:59:30".
  • trunk/LayoutTests/fast/forms/time/ValidityState-rangeUnderflow-time.html

    r98407 r103957  
    2727}
    2828
    29 function checkNotUnderflow(value, min, disabled)
     29function checkNotUnderflow(value, min, disabled, sanitized)
    3030{
    3131    input.value = value;
     
    3434    var underflow = input.validity.rangeUnderflow;
    3535    var resultText = 'The value "' + input.value + '" ' +
     36        (sanitized ? 'sanitized from "' + value + '" ' : '') +
    3637        (underflow ? 'underflows' : 'doesn\'t underflow') +
    3738        ' the minimum value "' + input.min + '"' + (disabled ? ' when disabled.' : '.');
     
    4041    else
    4142        testPassed(resultText);
     43}
     44
     45function checkSanitizedValueNotUnderflow(value, max, disabled)
     46{
     47    // For date types, invalid values are sanitized to "".
     48    checkNotUnderflow(value, max, disabled, true);
    4249}
    4350
     
    5259checkNotUnderflow('13:16', '11:00');
    5360checkNotUnderflow('13:16', '13:16');
    54 checkNotUnderflow('foo', '11:00');
     61checkSanitizedValueNotUnderflow('foo', '11:00');
    5562
    5663// Underflow cases
  • trunk/LayoutTests/fast/forms/time/ValidityState-typeMismatch-time-expected.txt

    r92746 r103957  
    1313PASS "23:59:59.1234567890" is a correct valid time string.
    1414PASS "00:00:00.0000000000" is a correct valid time string.
    15 PASS " 00:00 " is a correct invalid time string.
    16 PASS "1:23" is a correct invalid time string.
    17 PASS "011:11" is a correct invalid time string.
    18 PASS "ab:11" is a correct invalid time string.
    19 PASS "-1:11" is a correct invalid time string.
    20 PASS "24:11" is a correct invalid time string.
    21 PASS "11" is a correct invalid time string.
    22 PASS "11-" is a correct invalid time string.
    23 PASS "11:-2" is a correct invalid time string.
    24 PASS "11:60" is a correct invalid time string.
    25 PASS "11:2b" is a correct invalid time string.
    26 PASS "11:ab" is a correct invalid time string.
    27 PASS "11:034" is a correct invalid time string.
    28 PASS "23:45:" is a correct invalid time string.
    29 PASS "23:45:6" is a correct invalid time string.
    30 PASS "23:45:-1" is a correct invalid time string.
    31 PASS "23:45:70" is a correct invalid time string.
    32 PASS "23:45:zz" is a correct invalid time string.
    33 PASS "23:45:06." is a correct invalid time string.
    34 PASS "23:45:06.abc" is a correct invalid time string.
    35 PASS "23:45:06.789abc" is a correct invalid time string.
    36 PASS "invalid" is a correct valid time string when disabled.
     15PASS " 00:00 " is an invalid time string and was sanitized.
     16PASS "1:23" is an invalid time string and was sanitized.
     17PASS "011:11" is an invalid time string and was sanitized.
     18PASS "ab:11" is an invalid time string and was sanitized.
     19PASS "-1:11" is an invalid time string and was sanitized.
     20PASS "24:11" is an invalid time string and was sanitized.
     21PASS "11" is an invalid time string and was sanitized.
     22PASS "11-" is an invalid time string and was sanitized.
     23PASS "11:-2" is an invalid time string and was sanitized.
     24PASS "11:60" is an invalid time string and was sanitized.
     25PASS "11:2b" is an invalid time string and was sanitized.
     26PASS "11:ab" is an invalid time string and was sanitized.
     27PASS "11:034" is an invalid time string and was sanitized.
     28PASS "23:45:" is an invalid time string and was sanitized.
     29PASS "23:45:6" is an invalid time string and was sanitized.
     30PASS "23:45:-1" is an invalid time string and was sanitized.
     31PASS "23:45:70" is an invalid time string and was sanitized.
     32PASS "23:45:zz" is an invalid time string and was sanitized.
     33PASS "23:45:06." is an invalid time string and was sanitized.
     34PASS "23:45:06.abc" is an invalid time string and was sanitized.
     35PASS "23:45:06.789abc" is an invalid time string and was sanitized.
     36PASS "invalid" is an invalid time string and was sanitized while disabled.
    3737PASS successfullyParsed is true
    3838
  • trunk/LayoutTests/fast/forms/time/ValidityState-typeMismatch-time.html

    r98407 r103957  
    1212i.type = 'time';
    1313
    14 function check(value, mismatchExpected, disabled)
     14function check(value, disabled)
    1515{
    1616    i.value = value;
    1717    i.disabled = !!disabled;
    18     var actual = i.validity.typeMismatch;
    19     var didPass = actual == mismatchExpected;
    20     var resultText = '"' + value + '" is ' + (didPass ? 'a correct ' : 'an incorrect ') + (actual ? 'invalid' : 'valid') + ' time string' + (disabled ? ' when disabled.' : '.');
    21     if (didPass)
    22         testPassed(resultText);
    23     else
    24         testFailed(resultText);
     18
     19    if (i.validity.typeMismatch)
     20        testFailed('"' + value + '" had typeMismatch. This should not happen with sanitization.');
    2521}
    2622
    27 function shouldBeValid(value, disabled)
     23function shouldBeValid(value)
    2824{
    29     check(value, false, disabled);
     25    check(value);
     26    if ((value === '' && i.value === '') || (value !== '' && i.value !== ""))
     27        testPassed('"' + value + '" is a correct valid time string.');
     28    else
     29        testFailed('"' + value + '" is a valid time string that failed to be set on the input.');
    3030}
    3131
    32 function shouldBeInvalid(value)
     32function shouldBeInvalid(value, disabled)
    3333{
    34     check(value, true);
     34    check(value, disabled);
     35    if (i.value === '')
     36        testPassed('"' + value + '" is an invalid time string and was sanitized' + (disabled ? ' while disabled' : '') + '.');
     37    else
     38        testFailed('"' + value + '" is an invalid time string and was not sanitized' + (disabled ? ' while disabled' : '') + '.');
    3539}
    3640
     
    7074
    7175// Disabled
    72 shouldBeValid('invalid', true);
     76shouldBeInvalid('invalid', true);
    7377</script>
    7478<script src="../../js/resources/js-test-post.js"></script>
  • trunk/LayoutTests/fast/forms/week/ValidityState-rangeOverflow-week-expected.txt

    r92427 r103957  
    1010PASS The value "2010-W01" doesn't overflow the maximum value "2010-W02".
    1111PASS The value "2010-W01" doesn't overflow the maximum value "2011-W01".
    12 PASS The value "foo" doesn't overflow the maximum value "2011-W01".
     12PASS The value "" sanitized from "foo" doesn't overflow the maximum value "2011-W01".
    1313PASS The value "2010-W01" doesn't overflow the maximum value "0000-W01".
    1414PASS The value "2010-W01" overflows the maximum value "1582-W01".
  • trunk/LayoutTests/fast/forms/week/ValidityState-rangeOverflow-week.html

    r98407 r103957  
    2727}
    2828
    29 function checkNotOverflow(value, max, disabled)
     29function checkNotOverflow(value, max, disabled, sanitized)
    3030{
    3131    input.value = value;
     
    3434    var overflow = input.validity.rangeOverflow;
    3535    var resultText = 'The value "' + input.value + '" ' +
     36        (sanitized ? 'sanitized from "' + value + '" ' : '') +
    3637        (overflow ? 'overflows' : 'doesn\'t overflow') +
    3738        ' the maximum value "' + input.max + '"' + (disabled ? ' when disabled.' : '.');
     
    4041    else
    4142        testPassed(resultText);
     43}
     44
     45function checkSanitizedValueNotOverflow(value, max, disabled)
     46{
     47    // For date types, invalid values are sanitized to "".
     48    checkNotOverflow(value, max, disabled, true);
    4249}
    4350
     
    5158checkNotOverflow('2010-W01', '2010-W02');
    5259checkNotOverflow('2010-W01', '2011-W01');
    53 checkNotOverflow('foo', '2011-W01');
     60checkSanitizedValueNotOverflow('foo', '2011-W01');
    5461checkNotOverflow('2010-W01', '0000-W01'); // Invalid max value.
    5562
  • trunk/LayoutTests/fast/forms/week/ValidityState-rangeUnderflow-week-expected.txt

    r92427 r103957  
    1111PASS The value "2010-W01" doesn't underflow the minimum value "2009-W51".
    1212PASS The value "2010-W01" doesn't underflow the minimum value "2009-W01".
    13 PASS The value "foo" doesn't underflow the minimum value "2011-W01".
     13PASS The value "" sanitized from "foo" doesn't underflow the minimum value "2011-W01".
    1414PASS The value "2010-W01" undeflows the minimum value "2010-W02".
    1515PASS The value "9999-W01" undeflows the minimum value "10000-W12".
  • trunk/LayoutTests/fast/forms/week/ValidityState-rangeUnderflow-week.html

    r98407 r103957  
    2727}
    2828
    29 function checkNotUnderflow(value, min, disabled)
     29function checkNotUnderflow(value, min, disabled, sanitized)
    3030{
    3131    input.value = value;
     
    3434    var underflow = input.validity.rangeUnderflow;
    3535    var resultText = 'The value "' + input.value + '" ' +
     36        (sanitized ? 'sanitized from "' + value + '" ' : '') +
    3637        (underflow ? 'underflows' : 'doesn\'t underflow') +
    3738        ' the minimum value "' + input.min + '"' + (disabled ? ' when disabled.' : '.');
     
    4041    else
    4142        testPassed(resultText);
     43}
     44
     45function checkSanitizedValueNotUnderflow(value, max, disabled)
     46{
     47    // For date types, invalid values are sanitized to "".
     48    checkNotUnderflow(value, max, disabled, true);
    4249}
    4350
     
    5461checkNotUnderflow('2010-W01', '2009-W51');
    5562checkNotUnderflow('2010-W01', '2009-W01');
    56 checkNotUnderflow('foo', '2011-W01');
     63checkSanitizedValueNotUnderflow('foo', '2011-W01');
    5764
    5865// Underflow cases
  • trunk/LayoutTests/fast/forms/week/ValidityState-typeMismatch-week-expected.txt

    r92427 r103957  
    1313PASS "2003-W52" is a correct valid week string.
    1414PASS "1992-W53" is a correct valid week string.
    15 PASS " 2009-W01 " is a correct invalid week string.
    16 PASS "2009W01" is a correct invalid week string.
    17 PASS "2009-w01" is a correct invalid week string.
    18 PASS "2009-W1" is a correct invalid week string.
    19 PASS "2009-W001" is a correct invalid week string.
    20 PASS "a" is a correct invalid week string.
    21 PASS "-1-W09" is a correct invalid week string.
    22 PASS "0000-W52" is a correct invalid week string.
    23 PASS "2147483648-W01" is a correct invalid week string.
    24 PASS "275760-W38" is a correct invalid week string.
    25 PASS "2009-W00" is a correct invalid week string.
    26 PASS "2009-W-1" is a correct invalid week string.
    27 PASS "2004-W54" is a correct invalid week string.
    28 PASS "2003-W53" is a correct invalid week string.
    29 PASS "1992-W54" is a correct invalid week string.
    30 PASS "2009/09" is a correct invalid week string.
    31 PASS "200909" is a correct invalid week string.
    32 PASS "2009-Wxx" is a correct invalid week string.
    33 PASS "2009" is a correct invalid week string.
    34 PASS "invalid" is a correct valid week string when disabled.
     15PASS " 2009-W01 " is an invalid week string and was sanitized.
     16PASS "2009W01" is an invalid week string and was sanitized.
     17PASS "2009-w01" is an invalid week string and was sanitized.
     18PASS "2009-W1" is an invalid week string and was sanitized.
     19PASS "2009-W001" is an invalid week string and was sanitized.
     20PASS "a" is an invalid week string and was sanitized.
     21PASS "-1-W09" is an invalid week string and was sanitized.
     22PASS "0000-W52" is an invalid week string and was sanitized.
     23PASS "2147483648-W01" is an invalid week string and was sanitized.
     24PASS "275760-W38" is an invalid week string and was sanitized.
     25PASS "2009-W00" is an invalid week string and was sanitized.
     26PASS "2009-W-1" is an invalid week string and was sanitized.
     27PASS "2004-W54" is an invalid week string and was sanitized.
     28PASS "2003-W53" is an invalid week string and was sanitized.
     29PASS "1992-W54" is an invalid week string and was sanitized.
     30PASS "2009/09" is an invalid week string and was sanitized.
     31PASS "200909" is an invalid week string and was sanitized.
     32PASS "2009-Wxx" is an invalid week string and was sanitized.
     33PASS "2009" is an invalid week string and was sanitized.
     34PASS "invalid" is an invalid week string and was sanitized while disabled.
    3535PASS successfullyParsed is true
    3636
  • trunk/LayoutTests/fast/forms/week/ValidityState-typeMismatch-week.html

    r98407 r103957  
    1212i.type = 'week';
    1313
    14 function check(value, mismatchExpected, disabled)
     14function check(value, disabled)
    1515{
    1616    i.value = value;
    1717    i.disabled = !!disabled;
    18     var actual = i.validity.typeMismatch;
    19     var didPass = actual == mismatchExpected;
    20     var resultText = '"' + value + '" is ' + (didPass ? 'a correct ' : 'an incorrect ') + (actual ? 'invalid' : 'valid') + ' week string' + (disabled ? ' when disabled.' : '.');
    21     if (didPass)
    22         testPassed(resultText);
    23     else
    24         testFailed(resultText);
     18
     19    if (i.validity.typeMismatch)
     20        testFailed('"' + value + '" had typeMismatch. This should not happen with sanitization.');
    2521}
    2622
    27 function shouldBeValid(value, disabled)
     23function shouldBeValid(value)
    2824{
    29     check(value, false, disabled);
     25    check(value);
     26    if ((value === '' && i.value === '') || (value !== '' && i.value !== ""))
     27        testPassed('"' + value + '" is a correct valid week string.');
     28    else
     29        testFailed('"' + value + '" is a valid week string that failed to be set on the input.');
    3030}
    3131
    32 function shouldBeInvalid(value)
     32function shouldBeInvalid(value, disabled)
    3333{
    34     check(value, true);
     34    check(value, disabled);
     35    if (i.value === '')
     36        testPassed('"' + value + '" is an invalid week string and was sanitized' + (disabled ? ' while disabled' : '') + '.');
     37    else
     38        testFailed('"' + value + '" is an invalid week string and was not sanitized' + (disabled ? ' while disabled' : '') + '.');
    3539}
    3640
     
    6872
    6973// Disabled
    70 shouldBeValid('invalid', true);
     74shouldBeInvalid('invalid', true);
    7175</script>
    7276<script src="../../../fast/js/resources/js-test-post.js"></script>
  • trunk/Source/WebCore/ChangeLog

    r103955 r103957  
     12011-12-22  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Implement Date and Time Input Value Sanitization
     4        https://bugs.webkit.org/show_bug.cgi?id=59951
     5
     6        Sanitize non-parsable incoming strings to the empty string.
     7
     8        Reviewed by Kent Tamura.
     9
     10        Covered by existing tests.
     11
     12        * html/BaseDateAndTimeInputType.h:
     13        * html/BaseDateAndTimeInputType.cpp:
     14        (WebCore::BaseDateAndTimeInputType::sanitizeValue): check if the
     15        incoming string is valid. If not just return the empty string.
     16
    1172012-01-03  Julien Chaffraix  <jchaffraix@webkit.org>
    218
  • trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp

    r95901 r103957  
    213213}
    214214
     215String BaseDateAndTimeInputType::sanitizeValue(const String& proposedValue) const
     216{
     217    return typeMismatchFor(proposedValue) ? String() : proposedValue;
     218}
     219
    215220} // namespace WebCore
  • trunk/Source/WebCore/html/BaseDateAndTimeInputType.h

    r103400 r103957  
    6969    virtual String visibleValue() const OVERRIDE;
    7070    virtual String convertFromVisibleValue(const String&) const OVERRIDE;
     71    virtual String sanitizeValue(const String&) const OVERRIDE;
    7172};
    7273
Note: See TracChangeset for help on using the changeset viewer.