2009-11-18 Kent Tamura <tkent@chromium.org>
authortkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Nov 2009 02:15:17 +0000 (02:15 +0000)
committertkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Nov 2009 02:15:17 +0000 (02:15 +0000)
        Reviewed by Darin Adler.

        Tests for ValidityState.typeMismatch for the following types of INPUT element:
            date, datetime, datetime-local, month, time and week
        https://bugs.webkit.org/show_bug.cgi?id=31342

        * fast/forms/ValidityState-typeMismatch-date-expected.txt: Added.
        * fast/forms/ValidityState-typeMismatch-date.html: Added.
        * fast/forms/ValidityState-typeMismatch-datetime-expected.txt: Added.
        * fast/forms/ValidityState-typeMismatch-datetime.html: Added.
        * fast/forms/ValidityState-typeMismatch-datetimelocal-expected.txt: Added.
        * fast/forms/ValidityState-typeMismatch-datetimelocal.html: Added.
        * fast/forms/ValidityState-typeMismatch-month-expected.txt: Added.
        * fast/forms/ValidityState-typeMismatch-month.html: Added.
        * fast/forms/ValidityState-typeMismatch-time-expected.txt: Added.
        * fast/forms/ValidityState-typeMismatch-time.html: Added.
        * fast/forms/ValidityState-typeMismatch-week-expected.txt: Added.
        * fast/forms/ValidityState-typeMismatch-week.html: Added.
        * fast/forms/script-tests/ValidityState-typeMismatch-date.js: Added.
        * fast/forms/script-tests/ValidityState-typeMismatch-datetime.js: Added.
        * fast/forms/script-tests/ValidityState-typeMismatch-datetimelocal.js: Added.
        * fast/forms/script-tests/ValidityState-typeMismatch-month.js: Added.
        * fast/forms/script-tests/ValidityState-typeMismatch-time.js: Added.
        * fast/forms/script-tests/ValidityState-typeMismatch-week.js: Added.
2009-11-18  Kent Tamura  <tkent@chromium.org>

        Reviewed by Darin Adler.

        Add support for ValidityState.typeMismatch for the following INPUT types:
          date datetime datetime-local month time week
        https://bugs.webkit.org/show_bug.cgi?id=31342

        Tests: fast/forms/ValidityState-typeMismatch-date.html
               fast/forms/ValidityState-typeMismatch-datetime.html
               fast/forms/ValidityState-typeMismatch-datetimelocal.html
               fast/forms/ValidityState-typeMismatch-month.html
               fast/forms/ValidityState-typeMismatch-time.html
               fast/forms/ValidityState-typeMismatch-week.html

        * html/HTMLInputElement.cpp:
        (WebCore::HTMLInputElement::formStringToISODateTime): Check the type
          validity of the specified type and string using the ISODateTime class.
        * html/HTMLInputElement.h:
        * html/ValidityState.cpp:
        (WebCore::ValidityState::typeMismatch): Check the type validity
          for date, datetime, datetime-local, month, time and week with
          HTMLInputElemtn::formStringToISODateTime()

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51163 268f45cc-cd09-0410-ab3c-d52691b4dbfc

23 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/ValidityState-typeMismatch-date-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/ValidityState-typeMismatch-date.html [new file with mode: 0644]
LayoutTests/fast/forms/ValidityState-typeMismatch-datetime-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/ValidityState-typeMismatch-datetime.html [new file with mode: 0644]
LayoutTests/fast/forms/ValidityState-typeMismatch-datetimelocal-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/ValidityState-typeMismatch-datetimelocal.html [new file with mode: 0644]
LayoutTests/fast/forms/ValidityState-typeMismatch-month-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/ValidityState-typeMismatch-month.html [new file with mode: 0644]
LayoutTests/fast/forms/ValidityState-typeMismatch-time-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/ValidityState-typeMismatch-time.html [new file with mode: 0644]
LayoutTests/fast/forms/ValidityState-typeMismatch-week-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/ValidityState-typeMismatch-week.html [new file with mode: 0644]
LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-date.js [new file with mode: 0644]
LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-datetime.js [new file with mode: 0644]
LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-datetimelocal.js [new file with mode: 0644]
LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-month.js [new file with mode: 0644]
LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-time.js [new file with mode: 0644]
LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-week.js [new file with mode: 0644]
WebCore/ChangeLog
WebCore/html/HTMLInputElement.cpp
WebCore/html/HTMLInputElement.h
WebCore/html/ValidityState.cpp

index 731d96c..9543ac5 100644 (file)
@@ -2,6 +2,33 @@
 
         Reviewed by Darin Adler.
 
+        Tests for ValidityState.typeMismatch for the following types of INPUT element:
+            date, datetime, datetime-local, month, time and week
+        https://bugs.webkit.org/show_bug.cgi?id=31342
+
+        * fast/forms/ValidityState-typeMismatch-date-expected.txt: Added.
+        * fast/forms/ValidityState-typeMismatch-date.html: Added.
+        * fast/forms/ValidityState-typeMismatch-datetime-expected.txt: Added.
+        * fast/forms/ValidityState-typeMismatch-datetime.html: Added.
+        * fast/forms/ValidityState-typeMismatch-datetimelocal-expected.txt: Added.
+        * fast/forms/ValidityState-typeMismatch-datetimelocal.html: Added.
+        * fast/forms/ValidityState-typeMismatch-month-expected.txt: Added.
+        * fast/forms/ValidityState-typeMismatch-month.html: Added.
+        * fast/forms/ValidityState-typeMismatch-time-expected.txt: Added.
+        * fast/forms/ValidityState-typeMismatch-time.html: Added.
+        * fast/forms/ValidityState-typeMismatch-week-expected.txt: Added.
+        * fast/forms/ValidityState-typeMismatch-week.html: Added.
+        * fast/forms/script-tests/ValidityState-typeMismatch-date.js: Added.
+        * fast/forms/script-tests/ValidityState-typeMismatch-datetime.js: Added.
+        * fast/forms/script-tests/ValidityState-typeMismatch-datetimelocal.js: Added.
+        * fast/forms/script-tests/ValidityState-typeMismatch-month.js: Added.
+        * fast/forms/script-tests/ValidityState-typeMismatch-time.js: Added.
+        * fast/forms/script-tests/ValidityState-typeMismatch-week.js: Added.
+
+2009-11-18  Kent Tamura  <tkent@chromium.org>
+
+        Reviewed by Darin Adler.
+
         Add tests for ValidityState.stepMismatch.
         https://bugs.webkit.org/show_bug.cgi?id=31331
 
diff --git a/LayoutTests/fast/forms/ValidityState-typeMismatch-date-expected.txt b/LayoutTests/fast/forms/ValidityState-typeMismatch-date-expected.txt
new file mode 100644 (file)
index 0000000..0aa2c1e
--- /dev/null
@@ -0,0 +1,61 @@
+This test aims to check for typeMismatch flag with type=date input fields
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS "" is a correct valid date string.
+PASS "2009-09-07" is a correct valid date string.
+PASS "9999-12-31" is a correct valid date string.
+PASS "2147483647-12-31" is a correct valid date string.
+PASS "1582-10-15" is a correct valid date string.
+PASS "2009-01-31" is a correct valid date string.
+PASS "2009-02-28" is a correct valid date string.
+PASS "2009-03-31" is a correct valid date string.
+PASS "2009-04-30" is a correct valid date string.
+PASS "2009-05-31" is a correct valid date string.
+PASS "2009-06-30" is a correct valid date string.
+PASS "2009-07-31" is a correct valid date string.
+PASS "2009-08-31" is a correct valid date string.
+PASS "2009-09-30" is a correct valid date string.
+PASS "2009-10-31" is a correct valid date string.
+PASS "2009-11-30" is a correct valid date string.
+PASS "2009-12-31" is a correct valid date string.
+PASS "2008-02-29" is a correct valid date string.
+PASS "2000-02-29" is a correct valid date string.
+PASS " 2009-09-07 " is a correct invalid date string.
+PASS "a" is a correct invalid date string.
+PASS "-1-09-07" is a correct invalid date string.
+PASS "1581-09-07" is a correct invalid date string.
+PASS "1582-10-14" is a correct invalid date string.
+PASS "2147483648-12-31" is a correct invalid date string.
+PASS "2009/09/07" is a correct invalid date string.
+PASS "20090907" is a correct invalid date string.
+PASS "2009--2-07" is a correct invalid date string.
+PASS "2009-00-07" is a correct invalid date string.
+PASS "2009-13-07" is a correct invalid date string.
+PASS "1582-09-30" is a correct invalid date string.
+PASS "2009-xx-30" is a correct invalid date string.
+PASS "2009-01-32" is a correct invalid date string.
+PASS "2009-02-29" is a correct invalid date string.
+PASS "2009-03-32" is a correct invalid date string.
+PASS "2009-04-31" is a correct invalid date string.
+PASS "2009-05-32" is a correct invalid date string.
+PASS "2009-06-31" is a correct invalid date string.
+PASS "2009-07-32" is a correct invalid date string.
+PASS "2009-08-32" is a correct invalid date string.
+PASS "2009-09-31" is a correct invalid date string.
+PASS "2009-10-32" is a correct invalid date string.
+PASS "2009-11-31" is a correct invalid date string.
+PASS "2009-12-32" is a correct invalid date string.
+PASS "2100-02-29" is a correct invalid date string.
+PASS "2009-09-00" is a correct invalid date string.
+PASS "2009-09-" is a correct invalid date string.
+PASS "2009-09-7" is a correct invalid date string.
+PASS "2009-09-001" is a correct invalid date string.
+PASS "2009-09-xx" is a correct invalid date string.
+PASS "2009-09" is a correct invalid date string.
+PASS "2009" is a correct invalid date string.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/ValidityState-typeMismatch-date.html b/LayoutTests/fast/forms/ValidityState-typeMismatch-date.html
new file mode 100644 (file)
index 0000000..6686ae1
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/ValidityState-typeMismatch-date.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/ValidityState-typeMismatch-datetime-expected.txt b/LayoutTests/fast/forms/ValidityState-typeMismatch-datetime-expected.txt
new file mode 100644 (file)
index 0000000..9c57ce1
--- /dev/null
@@ -0,0 +1,39 @@
+This test aims to check for typeMismatch flag with type=datetime input fields
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS "" is a correct valid datetime string.
+PASS "2009-09-07T16:49Z" is a correct valid datetime string.
+PASS "2009-09-07T16:49:31Z" is a correct valid datetime string.
+PASS "2009-09-07T16:49:31.1Z" is a correct valid datetime string.
+PASS "2009-09-07T16:49:31.12Z" is a correct valid datetime string.
+PASS "2009-09-07T16:49:31.123Z" is a correct valid datetime string.
+PASS "2009-09-07T16:49:31.1234567890Z" is a correct valid datetime string.
+PASS "2147483647-12-31T23:59:59.999Z" is a correct valid datetime string.
+PASS "1582-10-15T00:00:00.000Z" is a correct valid datetime string.
+PASS "1582-10-15T00:00:00.000+00:00" is a correct valid datetime string.
+PASS "1582-10-15T01:30+01:30" is a correct valid datetime string.
+PASS "1582-10-15T00:00+01:00" is a correct valid datetime string.
+PASS " 2009-09-07T16:49Z " is a correct invalid datetime string.
+PASS "2009-09-07T16:49z" is a correct invalid datetime string.
+PASS "2009-09-07t16:49Z" is a correct invalid datetime string.
+PASS "2009-09-07T16:49" is a correct invalid datetime string.
+PASS "2009/09/07T16:49Z" is a correct invalid datetime string.
+PASS "a" is a correct invalid datetime string.
+PASS "-1-09-07T16:49Z" is a correct invalid datetime string.
+PASS "2009-09-07T16:49+23" is a correct invalid datetime string.
+PASS "2009-09-07T16:49+23:" is a correct invalid datetime string.
+PASS "2009-09-07T16:49+24:00" is a correct invalid datetime string.
+PASS "2009-09-07T16:49+23:60" is a correct invalid datetime string.
+PASS "2009-09-07T16:49-23" is a correct invalid datetime string.
+PASS "2009-09-07T16:49-23:" is a correct invalid datetime string.
+PASS "2009-09-07T16:49-24:00" is a correct invalid datetime string.
+PASS "2009-09-07T16:49-23:60" is a correct invalid datetime string.
+PASS "1582-10-14T23:59:59Z" is a correct invalid datetime string.
+PASS "2147483647-12-31T23:59-00:01" is a correct invalid datetime string.
+PASS "2147483648-01-01T00:00:00Z" is a correct invalid datetime string.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/ValidityState-typeMismatch-datetime.html b/LayoutTests/fast/forms/ValidityState-typeMismatch-datetime.html
new file mode 100644 (file)
index 0000000..9063e7c
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/ValidityState-typeMismatch-datetime.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/ValidityState-typeMismatch-datetimelocal-expected.txt b/LayoutTests/fast/forms/ValidityState-typeMismatch-datetimelocal-expected.txt
new file mode 100644 (file)
index 0000000..9897d06
--- /dev/null
@@ -0,0 +1,26 @@
+This test aims to check for typeMismatch flag with type=datetime-local input fields
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS "" is a correct valid datetime-local string.
+PASS "2009-09-07T16:49" is a correct valid datetime-local string.
+PASS "2009-09-07T16:49:31" is a correct valid datetime-local string.
+PASS "2009-09-07T16:49:31.1" is a correct valid datetime-local string.
+PASS "2009-09-07T16:49:31.12" is a correct valid datetime-local string.
+PASS "2009-09-07T16:49:31.123" is a correct valid datetime-local string.
+PASS "2009-09-07T16:49:31.1234567890" is a correct valid datetime-local string.
+PASS "2147483647-12-31T23:59:59.999" is a correct valid datetime-local string.
+PASS "1582-10-15T00:00:00.000" is a correct valid datetime-local string.
+PASS " 2009-09-07T16:49 " is a correct invalid datetime-local string.
+PASS "2009-09-07t16:49" is a correct invalid datetime-local string.
+PASS "2009-09-07 16:49" is a correct invalid datetime-local string.
+PASS "2009/09/07T16:49" is a correct invalid datetime-local string.
+PASS "a" is a correct invalid datetime-local string.
+PASS "-1-09-07T16:49" is a correct invalid datetime-local string.
+PASS "1582-10-14T23:59:59" is a correct invalid datetime-local string.
+PASS "2147483648-01-01T00:00:00" is a correct invalid datetime-local string.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/ValidityState-typeMismatch-datetimelocal.html b/LayoutTests/fast/forms/ValidityState-typeMismatch-datetimelocal.html
new file mode 100644 (file)
index 0000000..625abca
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/ValidityState-typeMismatch-datetimelocal.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/ValidityState-typeMismatch-month-expected.txt b/LayoutTests/fast/forms/ValidityState-typeMismatch-month-expected.txt
new file mode 100644 (file)
index 0000000..4ab8e4f
--- /dev/null
@@ -0,0 +1,41 @@
+This test aims to check for typeMismatch flag with type=month input fields
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS "" is a correct valid month string.
+PASS "1582-10" is a correct valid month string.
+PASS "9999-12" is a correct valid month string.
+PASS "2147483647-12" is a correct valid month string.
+PASS "2009-01" is a correct valid month string.
+PASS "2009-02" is a correct valid month string.
+PASS "2009-03" is a correct valid month string.
+PASS "2009-04" is a correct valid month string.
+PASS "2009-05" is a correct valid month string.
+PASS "2009-06" is a correct valid month string.
+PASS "2009-07" is a correct valid month string.
+PASS "2009-08" is a correct valid month string.
+PASS "2009-09" is a correct valid month string.
+PASS "2009-10" is a correct valid month string.
+PASS "2009-11" is a correct valid month string.
+PASS "2009-12" is a correct valid month string.
+PASS " 2009-09 " is a correct invalid month string.
+PASS "a" is a correct invalid month string.
+PASS "-1-09" is a correct invalid month string.
+PASS "1581-10" is a correct invalid month string.
+PASS "1582-09" is a correct invalid month string.
+PASS "2147483648-12" is a correct invalid month string.
+PASS "2009/09" is a correct invalid month string.
+PASS "200909" is a correct invalid month string.
+PASS "2009--2" is a correct invalid month string.
+PASS "2009-00" is a correct invalid month string.
+PASS "2009-13" is a correct invalid month string.
+PASS "2009-" is a correct invalid month string.
+PASS "2009-9" is a correct invalid month string.
+PASS "2009-009" is a correct invalid month string.
+PASS "2009-xx" is a correct invalid month string.
+PASS "2009" is a correct invalid month string.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/ValidityState-typeMismatch-month.html b/LayoutTests/fast/forms/ValidityState-typeMismatch-month.html
new file mode 100644 (file)
index 0000000..1269d39
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/ValidityState-typeMismatch-month.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/ValidityState-typeMismatch-time-expected.txt b/LayoutTests/fast/forms/ValidityState-typeMismatch-time-expected.txt
new file mode 100644 (file)
index 0000000..8f5b388
--- /dev/null
@@ -0,0 +1,39 @@
+This test aims to check for typeMismatch flag with type=time input fields
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS "" is a correct valid time string.
+PASS "00:00" is a correct valid time string.
+PASS "23:59" is a correct valid time string.
+PASS "23:59:59" is a correct valid time string.
+PASS "23:59:59.1" is a correct valid time string.
+PASS "23:59:59.12" is a correct valid time string.
+PASS "23:59:59.123" is a correct valid time string.
+PASS "23:59:59.1234567890" is a correct valid time string.
+PASS "00:00:00.0000000000" is a correct valid time string.
+PASS " 00:00 " is a correct invalid time string.
+PASS "1:23" is a correct invalid time string.
+PASS "011:11" is a correct invalid time string.
+PASS "ab:11" is a correct invalid time string.
+PASS "-1:11" is a correct invalid time string.
+PASS "24:11" is a correct invalid time string.
+PASS "11" is a correct invalid time string.
+PASS "11-" is a correct invalid time string.
+PASS "11:-2" is a correct invalid time string.
+PASS "11:60" is a correct invalid time string.
+PASS "11:2b" is a correct invalid time string.
+PASS "11:ab" is a correct invalid time string.
+PASS "11:034" is a correct invalid time string.
+PASS "23:45:" is a correct invalid time string.
+PASS "23:45:6" is a correct invalid time string.
+PASS "23:45:-1" is a correct invalid time string.
+PASS "23:45:70" is a correct invalid time string.
+PASS "23:45:zz" is a correct invalid time string.
+PASS "23:45:06." is a correct invalid time string.
+PASS "23:45:06.abc" is a correct invalid time string.
+PASS "23:45:06.789abc" is a correct invalid time string.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/ValidityState-typeMismatch-time.html b/LayoutTests/fast/forms/ValidityState-typeMismatch-time.html
new file mode 100644 (file)
index 0000000..764129a
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/ValidityState-typeMismatch-time.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/ValidityState-typeMismatch-week-expected.txt b/LayoutTests/fast/forms/ValidityState-typeMismatch-week-expected.txt
new file mode 100644 (file)
index 0000000..df9a26b
--- /dev/null
@@ -0,0 +1,35 @@
+This test aims to check for typeMismatch flag with type=week input fields
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS "" is a correct valid week string.
+PASS "1583-W01" is a correct valid week string.
+PASS "9999-W52" is a correct valid week string.
+PASS "2147483647-W52" is a correct valid week string.
+PASS "2009-W01" is a correct valid week string.
+PASS "2004-W53" is a correct valid week string.
+PASS "2003-W52" is a correct valid week string.
+PASS "1992-W53" is a correct valid week string.
+PASS " 2009-W01 " is a correct invalid week string.
+PASS "2009W01" is a correct invalid week string.
+PASS "2009-w01" is a correct invalid week string.
+PASS "2009-W1" is a correct invalid week string.
+PASS "2009-W001" is a correct invalid week string.
+PASS "a" is a correct invalid week string.
+PASS "-1-W09" is a correct invalid week string.
+PASS "1582-W52" is a correct invalid week string.
+PASS "2147483648-W01" is a correct invalid week string.
+PASS "2009-W00" is a correct invalid week string.
+PASS "2009-W-1" is a correct invalid week string.
+PASS "2004-W54" is a correct invalid week string.
+PASS "2003-W53" is a correct invalid week string.
+PASS "1992-W54" is a correct invalid week string.
+PASS "2009/09" is a correct invalid week string.
+PASS "200909" is a correct invalid week string.
+PASS "2009-Wxx" is a correct invalid week string.
+PASS "2009" is a correct invalid week string.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/ValidityState-typeMismatch-week.html b/LayoutTests/fast/forms/ValidityState-typeMismatch-week.html
new file mode 100644 (file)
index 0000000..95897a2
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/ValidityState-typeMismatch-week.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-date.js b/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-date.js
new file mode 100644 (file)
index 0000000..4972800
--- /dev/null
@@ -0,0 +1,83 @@
+description('This test aims to check for typeMismatch flag with type=date input fields');
+var i = document.createElement('input');
+i.type = 'date';
+
+function check(value, mismatchExpected)
+{
+    i.value = value;
+    var actual = i.validity.typeMismatch;
+    var didPass = actual == mismatchExpected;
+    var resultText = '"' + value + '" is ' + (didPass ? 'a correct ' : 'an incorrect ') + (actual ? 'invalid' : 'valid') + ' date string.';
+    if (didPass)
+        testPassed(resultText);
+    else
+        testFailed(resultText);
+}
+
+function shouldBeValid(value)
+{
+    check(value, false);
+}
+
+function shouldBeInvalid(value)
+{
+    check(value, true);
+}
+
+// Valid values
+shouldBeValid('');
+shouldBeValid('2009-09-07');
+shouldBeValid('9999-12-31');
+shouldBeValid('2147483647-12-31');
+shouldBeValid('1582-10-15');
+shouldBeValid('2009-01-31');
+shouldBeValid('2009-02-28');
+shouldBeValid('2009-03-31');
+shouldBeValid('2009-04-30');
+shouldBeValid('2009-05-31');
+shouldBeValid('2009-06-30');
+shouldBeValid('2009-07-31');
+shouldBeValid('2009-08-31');
+shouldBeValid('2009-09-30');
+shouldBeValid('2009-10-31');
+shouldBeValid('2009-11-30');
+shouldBeValid('2009-12-31');
+shouldBeValid('2008-02-29');
+shouldBeValid('2000-02-29');
+
+// Invalid values
+shouldBeInvalid(' 2009-09-07 ');
+shouldBeInvalid('a');
+shouldBeInvalid('-1-09-07');
+shouldBeInvalid('1581-09-07');
+shouldBeInvalid('1582-10-14');
+shouldBeInvalid('2147483648-12-31');
+shouldBeInvalid('2009/09/07');
+shouldBeInvalid('20090907');
+shouldBeInvalid('2009--2-07');
+shouldBeInvalid('2009-00-07');
+shouldBeInvalid('2009-13-07');
+shouldBeInvalid('1582-09-30');
+shouldBeInvalid('2009-xx-30');
+shouldBeInvalid('2009-01-32');
+shouldBeInvalid('2009-02-29');
+shouldBeInvalid('2009-03-32');
+shouldBeInvalid('2009-04-31');
+shouldBeInvalid('2009-05-32');
+shouldBeInvalid('2009-06-31');
+shouldBeInvalid('2009-07-32');
+shouldBeInvalid('2009-08-32');
+shouldBeInvalid('2009-09-31');
+shouldBeInvalid('2009-10-32');
+shouldBeInvalid('2009-11-31');
+shouldBeInvalid('2009-12-32');
+shouldBeInvalid('2100-02-29');
+shouldBeInvalid('2009-09-00');
+shouldBeInvalid('2009-09-');
+shouldBeInvalid('2009-09-7');
+shouldBeInvalid('2009-09-001');
+shouldBeInvalid('2009-09-xx');
+shouldBeInvalid('2009-09');
+shouldBeInvalid('2009');
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-datetime.js b/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-datetime.js
new file mode 100644 (file)
index 0000000..e8f5ddd
--- /dev/null
@@ -0,0 +1,61 @@
+description('This test aims to check for typeMismatch flag with type=datetime input fields');
+var i = document.createElement('input');
+i.type = 'datetime';
+
+function check(value, mismatchExpected)
+{
+    i.value = value;
+    var actual = i.validity.typeMismatch;
+    var didPass = actual == mismatchExpected;
+    var resultText = '"' + value + '" is ' + (didPass ? 'a correct ' : 'an incorrect ') + (actual ? 'invalid' : 'valid') + ' datetime string.';
+    if (didPass)
+        testPassed(resultText);
+    else
+        testFailed(resultText);
+}
+
+function shouldBeValid(value)
+{
+    check(value, false);
+}
+
+function shouldBeInvalid(value)
+{
+    check(value, true);
+}
+
+// Valid values
+shouldBeValid('');
+shouldBeValid('2009-09-07T16:49Z');
+shouldBeValid('2009-09-07T16:49:31Z');
+shouldBeValid('2009-09-07T16:49:31.1Z');
+shouldBeValid('2009-09-07T16:49:31.12Z');
+shouldBeValid('2009-09-07T16:49:31.123Z');
+shouldBeValid('2009-09-07T16:49:31.1234567890Z');
+shouldBeValid('2147483647-12-31T23:59:59.999Z');
+shouldBeValid('1582-10-15T00:00:00.000Z');
+shouldBeValid('1582-10-15T00:00:00.000+00:00');
+shouldBeValid('1582-10-15T01:30+01:30');
+shouldBeValid('1582-10-15T00:00+01:00');
+
+// Invalid values
+shouldBeInvalid(' 2009-09-07T16:49Z ');
+shouldBeInvalid('2009-09-07T16:49z');
+shouldBeInvalid('2009-09-07t16:49Z');
+shouldBeInvalid('2009-09-07T16:49');
+shouldBeInvalid('2009/09/07T16:49Z');
+shouldBeInvalid('a');
+shouldBeInvalid('-1-09-07T16:49Z');
+shouldBeInvalid('2009-09-07T16:49+23');
+shouldBeInvalid('2009-09-07T16:49+23:');
+shouldBeInvalid('2009-09-07T16:49+24:00');
+shouldBeInvalid('2009-09-07T16:49+23:60');
+shouldBeInvalid('2009-09-07T16:49-23');
+shouldBeInvalid('2009-09-07T16:49-23:');
+shouldBeInvalid('2009-09-07T16:49-24:00');
+shouldBeInvalid('2009-09-07T16:49-23:60');
+shouldBeInvalid('1582-10-14T23:59:59Z');
+shouldBeInvalid('2147483647-12-31T23:59-00:01');
+shouldBeInvalid('2147483648-01-01T00:00:00Z');
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-datetimelocal.js b/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-datetimelocal.js
new file mode 100644 (file)
index 0000000..c406e12
--- /dev/null
@@ -0,0 +1,48 @@
+description('This test aims to check for typeMismatch flag with type=datetime-local input fields');
+var i = document.createElement('input');
+i.type = 'datetime-local';
+
+function check(value, mismatchExpected)
+{
+    i.value = value;
+    var actual = i.validity.typeMismatch;
+    var didPass = actual == mismatchExpected;
+    var resultText = '"' + value + '" is ' + (didPass ? 'a correct ' : 'an incorrect ') + (actual ? 'invalid' : 'valid') + ' datetime-local string.';
+    if (didPass)
+        testPassed(resultText);
+    else
+        testFailed(resultText);
+}
+
+function shouldBeValid(value)
+{
+    check(value, false);
+}
+
+function shouldBeInvalid(value)
+{
+    check(value, true);
+}
+
+// Valid values
+shouldBeValid('');
+shouldBeValid('2009-09-07T16:49');
+shouldBeValid('2009-09-07T16:49:31');
+shouldBeValid('2009-09-07T16:49:31.1');
+shouldBeValid('2009-09-07T16:49:31.12');
+shouldBeValid('2009-09-07T16:49:31.123');
+shouldBeValid('2009-09-07T16:49:31.1234567890');
+shouldBeValid('2147483647-12-31T23:59:59.999');
+shouldBeValid('1582-10-15T00:00:00.000');
+
+// Invalid values
+shouldBeInvalid(' 2009-09-07T16:49 ');
+shouldBeInvalid('2009-09-07t16:49');
+shouldBeInvalid('2009-09-07 16:49');
+shouldBeInvalid('2009/09/07T16:49');
+shouldBeInvalid('a');
+shouldBeInvalid('-1-09-07T16:49');
+shouldBeInvalid('1582-10-14T23:59:59');
+shouldBeInvalid('2147483648-01-01T00:00:00');
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-month.js b/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-month.js
new file mode 100644 (file)
index 0000000..1276204
--- /dev/null
@@ -0,0 +1,63 @@
+description('This test aims to check for typeMismatch flag with type=month input fields');
+var i = document.createElement('input');
+i.type = 'month';
+
+function check(value, mismatchExpected)
+{
+    i.value = value;
+    var actual = i.validity.typeMismatch;
+    var didPass = actual == mismatchExpected;
+    var resultText = '"' + value + '" is ' + (didPass ? 'a correct ' : 'an incorrect ') + (actual ? 'invalid' : 'valid') + ' month string.';
+    if (didPass)
+        testPassed(resultText);
+    else
+        testFailed(resultText);
+}
+
+function shouldBeValid(value)
+{
+    check(value, false);
+}
+
+function shouldBeInvalid(value)
+{
+    check(value, true);
+}
+
+// Valid values
+shouldBeValid('');
+shouldBeValid('1582-10');
+shouldBeValid('9999-12');
+shouldBeValid('2147483647-12');
+shouldBeValid('2009-01');
+shouldBeValid('2009-02');
+shouldBeValid('2009-03');
+shouldBeValid('2009-04');
+shouldBeValid('2009-05');
+shouldBeValid('2009-06');
+shouldBeValid('2009-07');
+shouldBeValid('2009-08');
+shouldBeValid('2009-09');
+shouldBeValid('2009-10');
+shouldBeValid('2009-11');
+shouldBeValid('2009-12');
+
+// Invalid values
+shouldBeInvalid(' 2009-09 ');
+shouldBeInvalid('a');
+shouldBeInvalid('-1-09');
+shouldBeInvalid('1581-10');
+shouldBeInvalid('1582-09');
+shouldBeInvalid('2147483648-12');
+shouldBeInvalid('2009/09');
+shouldBeInvalid('200909');
+shouldBeInvalid('2009--2');
+shouldBeInvalid('2009-00');
+shouldBeInvalid('2009-13');
+shouldBeInvalid('2009-');
+shouldBeInvalid('2009-9');
+shouldBeInvalid('2009-009');
+shouldBeInvalid('2009-xx');
+shouldBeInvalid('2009');
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-time.js b/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-time.js
new file mode 100644 (file)
index 0000000..4aaded4
--- /dev/null
@@ -0,0 +1,61 @@
+description('This test aims to check for typeMismatch flag with type=time input fields');
+var i = document.createElement('input');
+i.type = 'time';
+
+function check(value, mismatchExpected)
+{
+    i.value = value;
+    var actual = i.validity.typeMismatch;
+    var didPass = actual == mismatchExpected;
+    var resultText = '"' + value + '" is ' + (didPass ? 'a correct ' : 'an incorrect ') + (actual ? 'invalid' : 'valid') + ' time string.';
+    if (didPass)
+        testPassed(resultText);
+    else
+        testFailed(resultText);
+}
+
+function shouldBeValid(value)
+{
+    check(value, false);
+}
+
+function shouldBeInvalid(value)
+{
+    check(value, true);
+}
+
+// Valid values
+shouldBeValid('');
+shouldBeValid('00:00');
+shouldBeValid('23:59');
+shouldBeValid('23:59:59');
+shouldBeValid('23:59:59.1');
+shouldBeValid('23:59:59.12');
+shouldBeValid('23:59:59.123');
+shouldBeValid('23:59:59.1234567890');
+shouldBeValid('00:00:00.0000000000');
+
+// Invalid values
+shouldBeInvalid(' 00:00 ');
+shouldBeInvalid('1:23');
+shouldBeInvalid('011:11');
+shouldBeInvalid('ab:11');
+shouldBeInvalid('-1:11');
+shouldBeInvalid('24:11');
+shouldBeInvalid('11');
+shouldBeInvalid('11-');
+shouldBeInvalid('11:-2');
+shouldBeInvalid('11:60');
+shouldBeInvalid('11:2b');
+shouldBeInvalid('11:ab');
+shouldBeInvalid('11:034');
+shouldBeInvalid('23:45:');
+shouldBeInvalid('23:45:6');
+shouldBeInvalid('23:45:-1');
+shouldBeInvalid('23:45:70');
+shouldBeInvalid('23:45:zz');
+shouldBeInvalid('23:45:06.');
+shouldBeInvalid('23:45:06.abc');
+shouldBeInvalid('23:45:06.789abc');
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-week.js b/LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-week.js
new file mode 100644 (file)
index 0000000..6b1d9dd
--- /dev/null
@@ -0,0 +1,57 @@
+description('This test aims to check for typeMismatch flag with type=week input fields');
+var i = document.createElement('input');
+i.type = 'week';
+
+function check(value, mismatchExpected)
+{
+    i.value = value;
+    var actual = i.validity.typeMismatch;
+    var didPass = actual == mismatchExpected;
+    var resultText = '"' + value + '" is ' + (didPass ? 'a correct ' : 'an incorrect ') + (actual ? 'invalid' : 'valid') + ' week string.';
+    if (didPass)
+        testPassed(resultText);
+    else
+        testFailed(resultText);
+}
+
+function shouldBeValid(value)
+{
+    check(value, false);
+}
+
+function shouldBeInvalid(value)
+{
+    check(value, true);
+}
+
+// Valid values
+shouldBeValid('');
+shouldBeValid('1583-W01');
+shouldBeValid('9999-W52');
+shouldBeValid('2147483647-W52');
+shouldBeValid('2009-W01');
+shouldBeValid('2004-W53');  // 2004 started on Thursday.
+shouldBeValid('2003-W52');  // 2003 started on Wednesday, but wasn't a leap year.
+shouldBeValid('1992-W53');  // 1992 started on Wednesday, and was a leap year.
+
+// Invalid values
+shouldBeInvalid(' 2009-W01 ');
+shouldBeInvalid('2009W01');
+shouldBeInvalid('2009-w01');
+shouldBeInvalid('2009-W1');
+shouldBeInvalid('2009-W001');
+shouldBeInvalid('a');
+shouldBeInvalid('-1-W09');
+shouldBeInvalid('1582-W52');
+shouldBeInvalid('2147483648-W01');
+shouldBeInvalid('2009-W00');
+shouldBeInvalid('2009-W-1');
+shouldBeInvalid('2004-W54');  // 2004 started on Thursday.
+shouldBeInvalid('2003-W53');  // 2003 started on Wednesday, but wasn't a leap year.
+shouldBeInvalid('1992-W54');  // 1992 started on Wednesday, and was a leap year.
+shouldBeInvalid('2009/09');
+shouldBeInvalid('200909');
+shouldBeInvalid('2009-Wxx');
+shouldBeInvalid('2009');
+
+var successfullyParsed = true;
index db73bf6..dcea903 100644 (file)
@@ -1,3 +1,27 @@
+2009-11-18  Kent Tamura  <tkent@chromium.org>
+
+        Reviewed by Darin Adler.
+
+        Add support for ValidityState.typeMismatch for the following INPUT types:
+          date datetime datetime-local month time week
+        https://bugs.webkit.org/show_bug.cgi?id=31342
+
+        Tests: fast/forms/ValidityState-typeMismatch-date.html
+               fast/forms/ValidityState-typeMismatch-datetime.html
+               fast/forms/ValidityState-typeMismatch-datetimelocal.html
+               fast/forms/ValidityState-typeMismatch-month.html
+               fast/forms/ValidityState-typeMismatch-time.html
+               fast/forms/ValidityState-typeMismatch-week.html
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::formStringToISODateTime): Check the type
+          validity of the specified type and string using the ISODateTime class.
+        * html/HTMLInputElement.h:
+        * html/ValidityState.cpp:
+        (WebCore::ValidityState::typeMismatch): Check the type validity
+          for date, datetime, datetime-local, month, time and week with
+          HTMLInputElemtn::formStringToISODateTime()
+
 2009-11-18  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Oliver Hunt.
index 81a3d72..bb8fd26 100644 (file)
@@ -45,6 +45,7 @@
 #include "HTMLImageLoader.h"
 #include "HTMLNames.h"
 #include "HTMLOptionElement.h"
+#include "ISODateTime.h"
 #include "ScriptEventListener.h"
 #include "KeyboardEvent.h"
 #include "LocalizedStrings.h"
@@ -2007,6 +2008,34 @@ bool HTMLInputElement::formStringToDouble(const String& src, double* out)
     return true;
 }
 
+bool HTMLInputElement::formStringToISODateTime(InputType type, const String& formString, ISODateTime* out)
+{
+    ISODateTime ignoredResult;
+    if (!out)
+        out = &ignoredResult;
+    const UChar* characters = formString.characters();
+    unsigned length = formString.length();
+    unsigned end;
+
+    switch (type) {
+    case DATE:
+        return out->parseDate(characters, length, 0, end) && end == length;
+    case DATETIME:
+        return out->parseDateTime(characters, length, 0, end) && end == length;
+    case DATETIMELOCAL:
+        return out->parseDateTimeLocal(characters, length, 0, end) && end == length;
+    case MONTH:
+        return out->parseMonth(characters, length, 0, end) && end == length;
+    case WEEK:
+        return out->parseWeek(characters, length, 0, end) && end == length;
+    case TIME:
+        return out->parseTime(characters, length, 0, end) && end == length;
+    default:
+        ASSERT_NOT_REACHED();
+        return false;
+    }
+}
+
 #if ENABLE(DATALIST)
 HTMLElement* HTMLInputElement::list() const
 {
index ff06f15..88a8596 100644 (file)
@@ -34,6 +34,7 @@ class FileList;
 class HTMLDataListElement;
 class HTMLImageLoader;
 class HTMLOptionElement;
+class ISODateTime;
 class KURL;
 class VisibleSelection;
 
@@ -247,6 +248,10 @@ public:
     // If the conversion fails, the return value is false. Take care that leading or trailing unnecessary characters make failures.  This returns false for an empty string input.
     // The double* parameter may be 0.
     static bool formStringToDouble(const String&, double*);
+    // Parses the specified string as the InputType, and returns true if it is successfully parsed.
+    // An instance pointed by the ISODateTime* parameter will have parsed values and be
+    // modified even if the parsing fails.  The ISODateTime* parameter may be 0.
+    static bool formStringToISODateTime(InputType, const String&, ISODateTime*);
     
 protected:
     virtual void willMoveToNewOwnerDocument();
index 2c6e7a5..c67a3c4 100644 (file)
@@ -74,6 +74,13 @@ bool ValidityState::typeMismatch()
 
         return false;
     }
+    case HTMLInputElement::DATE:
+    case HTMLInputElement::DATETIME:
+    case HTMLInputElement::DATETIMELOCAL:
+    case HTMLInputElement::MONTH:
+    case HTMLInputElement::TIME:
+    case HTMLInputElement::WEEK:
+        return !HTMLInputElement::formStringToISODateTime(input->inputType(), value, 0);
     default:
         return false;
     }