Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: LayoutTests/imported/web-platform-tests/html/semantics/forms/the-input-element/date.html

Issue 1144143009: W3C Test: Import web-platform-tests/html/semantics (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Inputs Date</title>
5 <link rel="author" title="Morishita Hiromitsu" href="mailto:hero@asterisk-wo rks.jp">
6 <link rel="help" href="https://html.spec.whatwg.org/multipage/#date-state-(t ype=date)">
7 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dates-and-tim es">
8 <script src="../../../../../../resources/testharness.js"></script>
9 <script src="../../../../../../resources/testharnessreport.js"></script>
10 </head>
11 <body>
12 <h1>Inputs Date</h1>
13 <div style="display: none">
14 <input id="valid" type="date" value="2011-11-01" min="2011-01-01" max="201 1-12-31" />
15 <input id="too_small_value" type="date" value="1999-01-31" min="2011-01-01 " max="2011-12-31"/>
16 <input id="too_large_value" type="date" value="2099-01-31" min="2011-01-01 " max="2011-12-31"/>
17 <input id="invalid_min" type="date" value="2011-01-01" min="1999-1" max="2 011-12-31"/>
18 <input id="invalid_max" type="date" value="2011-01-01" min="2011-01-01" ma x="2011-13-162-777"/>
19 <input id="min_larger_than_max" type="date" value="2011-01-01" min="2099-0 1" max="2011-12-31"/>
20 <input id="invalid_value" type="date" value="invalid-date" min="2011-01-01 " max="2011-12-31"/>
21 </div>
22
23 <div id="log"></div>
24
25 <script type="text/javascript">
26 test(function() {
27 assert_equals(document.getElementById("valid").type, "date")
28 }, "date type support on input element");
29
30 test(function() {
31 assert_equals(document.getElementById("valid").value, "2011-11-01");
32 assert_equals(document.getElementById("too_small_value").value, "2011-01 -01");
33 assert_equals(document.getElementById("too_large_value").value, "2011-12 -31");
34 }, "The value attribute, if specified and not empty, must have a value tha t is a valid date string.");
35
36 test(function() {
37 assert_equals(document.getElementById("valid").min, "2011-01-01"),
38 assert_equals(document.getElementById("invalid_min").min, "")
39 }, "The min attribute, if specified, must have a value that is a valid dat e string.");
40
41 test(function() {
42 assert_equals(document.getElementById("valid").max, "2011-12-31"),
43 assert_equals(document.getElementById("min_larger_than_max").max, "2099- 01"),
44 assert_equals(document.getElementById("invalid_max").max, "")
45 },"The max attribute, if specified, must have a value that is a valid date string.");
46
47 test(function() {
48 assert_equals(document.getElementById("invalid_value").value, "");
49 }, "User agents must not allow the user to set the value to a non-empty st ring that is not a valid date string.");
50 test(function() {
51 var numDays = [
52 // the number of days in month month of year year is: 31 if month is 1 , 3, 5, 7, 8, 10, or 12;
53 {value: "2014-01-31", expected: "2014-01-31", testname: "January has 3 1 days"},
54 {value: "2014-01-32", expected: "", testname: "January has 31 days"},
55 {value: "2014-03-31", expected: "2014-03-31", testname: "March has 31 days"},
56 {value: "2014-03-32", expected: "", testname: "March has 31 days"},
57 {value: "2014-05-31", expected: "2014-05-31", testname: "May has 31 da ys"},
58 {value: "2014-05-32", expected: "", testname: "May has 31 days"},
59 {value: "2014-07-31", expected: "2014-07-31", testname: "July has 31 d ays"},
60 {value: "2014-07-32", expected: "", testname: "July has 31 days"},
61 {value: "2014-08-31", expected: "2014-08-31", testname: "August has 31 days"},
62 {value: "2014-08-32", expected: "", testname: "August has 31 days"},
63 {value: "2014-10-31", expected: "2014-10-31", testname: "October has 3 1 days"},
64 {value: "2014-10-32", expected: "", testname: "October has 31 days"},
65 {value: "2014-12-31", expected: "2014-12-31", testname: "December has 31 days"},
66 {value: "2014-12-32", expected: "", testname: "December has 31 days"},
67 // the number of days in month month of year year is: 30 if month is 4 , 6, 9, or 11;
68 {value: "2014-04-30", expected: "2014-04-30", testname: "April has 30 days"},
69 {value: "2014-04-31", expected: "", testname: "April has 30 days"},
70 {value: "2014-06-30", expected: "2014-06-30", testname: "June has 30 d ays"},
71 {value: "2014-06-31", expected: "", testname: "June has 30 days"},
72 {value: "2014-09-30", expected: "2014-09-30", testname: "September has 30 days"},
73 {value: "2014-09-31", expected: "", testname: "September has 30 days"} ,
74 {value: "2014-11-30", expected: "2014-11-30", testname: "November has 30 days"},
75 {value: "2014-11-31", expected: "", testname: "November has 30 days"},
76 // leap years
77 {value: "2014-02-28", expected: "2014-02-28", testname: "2014 is not a leap year: February has 28 days"},
78 {value: "2014-02-29", expected: "", testname: "2014 is not a leap year : February has 28 days: value should be empty"},
79 {value: "2016-02-29", expected: "2016-02-29", testname: "2016 is a lea p year: February has 29 days"}
80 ];
81 for (var i = 0; i < numDays.length; i++) {
82 var input = document.createElement("input");
83 input.type = "date";
84 input.value = numDays[i].value;
85 assert_equals(input.value, numDays[i].expected, numDays[i].testname);
86 }
87 }, "Number of days");
88 </script>
89 </body>
90 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698