Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / date / ValidityState-stepMismatch-date.html
blobeb57a9c37ab4858830aacf4a33075b4fb7b85605
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('Check stepMismatch results for type=date.');
12 var input = document.createElement('input');
13 document.body.appendChild(input);
15 function stepMismatchFor(value, step, min, disabled) {
16 input.min = min;
17 input.step = step;
18 input.value = value;
19 input.disabled = !!disabled;
20 return input.validity.stepMismatch;
23 input.type = 'date';
24 debug('Empty values');
25 shouldBeFalse('stepMismatchFor("", null, null)');
26 shouldBeFalse('stepMismatchFor("", "2", "1969-12-31")');
27 debug('Normal step values');
28 shouldBeTrue('stepMismatchFor("2010-02-10", "2", "2010-02-09")');
29 shouldBeFalse('stepMismatchFor("2010-02-09", "2", "2010-02-09")');
30 shouldBeFalse('stepMismatchFor("2010-02-11", "2", "2010-02-09")');
31 shouldBeTrue('stepMismatchFor("1800-11-11", "3", "1800-11-09")');
32 shouldBeFalse('stepMismatchFor("1800-11-09", "3", "1800-11-09")');
33 shouldBeFalse('stepMismatchFor("1800-11-12", "3", "1800-11-09")');
34 shouldBeTrue('stepMismatchFor("275760-09-13", "3", "275760-09-11")');
35 shouldBeFalse('stepMismatchFor("275760-09-13", "2", "275760-09-11")');
36 debug('Implicit step base');
37 shouldBeTrue('stepMismatchFor("1970-01-02", "2", null)');
38 shouldBeFalse('stepMismatchFor("1970-01-03", "2", null)');
39 debug('Fractional step values');
40 shouldBeFalse('stepMismatchFor("2010-02-10", "0.1", "2010-02-09")');
41 shouldBeFalse('stepMismatchFor("2010-02-10", "1.1", "2010-02-09")');
42 shouldBeTrue('stepMismatchFor("2010-02-10", "1.9", "2010-02-09")');
43 debug('Invalid or no step values');
44 shouldBeFalse('stepMismatchFor("2010-02-10", null, "2010-02-09")');
45 shouldBeFalse('stepMismatchFor("2010-02-10", "-1", "2010-02-09")');
46 shouldBeFalse('stepMismatchFor("2010-02-10", "foo", "2010-02-09")');
47 debug('Special step value');
48 shouldBeFalse('stepMismatchFor("2010-02-10", "any", "2010-02-09")');
49 debug('Disabled');
50 shouldBeFalse('stepMismatchFor("2010-02-10", "2", "2010-02-09", true)');
52 debug('');
53 </script>
54 </body>
55 </html>