Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / week / input-valueasdate-week.html
blob39ef433131272707ce7727a81b08e799bfeb442b
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script>
10 description('Tests for .valueAsDate with &lt;input type=week>.');
12 var input = document.createElement('input');
13 input.type = 'week';
15 function valueAsDateFor(stringValue) {
16 input.value = stringValue;
17 return input.valueAsDate;
20 function setValueAsDateAndGetValue(year, month, day) {
21 var date = new Date();
22 date.setTime(Date.UTC(year, month, day));
23 if (year < 100)
24 date.setUTCFullYear(year);
25 input.valueAsDate = date;
26 return input.value;
29 shouldBe('valueAsDateFor("")', 'null');
30 // January 1st is Monday. W01 starts on January 1nd.
31 shouldBe('valueAsDateFor("2007-W01").getTime()', 'Date.UTC(2007, 0, 1)');
32 // January 1st is Tuesday. W01 starts on December 31th.
33 shouldBe('valueAsDateFor("2008-W01").getTime()', 'Date.UTC(2007, 11, 31)');
34 // January 1st is Wednesday. W01 starts on December 29th.
35 shouldBe('valueAsDateFor("2003-W01").getTime()', 'Date.UTC(2002, 11, 30)');
36 // January 1st is Thursday. W01 starts on December 29th.
37 shouldBe('valueAsDateFor("2004-W01").getTime()', 'Date.UTC(2003, 11, 29, 0, 0, 0, 0)');
38 // January 1st is Friday. W01 starts on January 4th.
39 shouldBe('valueAsDateFor("2010-W01").getTime()', 'Date.UTC(2010, 0, 4)');
40 // January 1st is Saturday. W01 starts on January 3rd.
41 shouldBe('valueAsDateFor("2005-W01").getTime()', 'Date.UTC(2005, 0, 3)');
42 // January 1st is Sunday. W01 starts on January 2nd.
43 shouldBe('valueAsDateFor("2006-W01").getTime()', 'Date.UTC(2006, 0, 2)');
45 debug('Various January 1st:');
46 shouldBe('setValueAsDateAndGetValue(1, 0, 1)', '"0001-W01"');
47 shouldBe('setValueAsDateAndGetValue(2007, 0, 1)', '"2007-W01"');
48 shouldBe('setValueAsDateAndGetValue(2008, 0, 1)', '"2008-W01"');
49 shouldBe('setValueAsDateAndGetValue(2003, 0, 1)', '"2003-W01"');
50 shouldBe('setValueAsDateAndGetValue(2004, 0, 1)', '"2004-W01"');
51 shouldBe('setValueAsDateAndGetValue(2010, 0, 1)', '"2009-W53"');
52 shouldBe('setValueAsDateAndGetValue(2005, 0, 1)', '"2004-W53"');
53 shouldBe('setValueAsDateAndGetValue(2006, 0, 1)', '"2005-W52"');
55 debug('Normal cases:');
56 shouldBe('setValueAsDateAndGetValue(2010, 0, 3)', '"2009-W53"');
57 shouldBe('setValueAsDateAndGetValue(2010, 0, 4)', '"2010-W01"');
58 shouldBe('setValueAsDateAndGetValue(2010, 0, 10)', '"2010-W01"');
59 shouldBe('setValueAsDateAndGetValue(2010, 0, 11)', '"2010-W02"');
60 shouldBe('setValueAsDateAndGetValue(2010, 0, 17)', '"2010-W02"');
61 shouldBe('setValueAsDateAndGetValue(2010, 11, 31)', '"2010-W52"');
63 debug('Around the minimum value:');
64 // Gregorian calendar started in 1582. We don't support that year.
65 shouldBe('setValueAsDateAndGetValue(0, 11, 31)', '""');
66 shouldBe('setValueAsDateAndGetValue(0, 0, 1)', '""');
67 </script>
68 </body>
69 </html>