Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / week / ValidityState-stepMismatch-week.html
blob7ef98a642ec279c700fec61d709f7d0eda5b45d5
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=week.');
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 = 'week';
24 debug('Empty values');
25 shouldBeFalse('stepMismatchFor("", null, null)');
26 shouldBeFalse('stepMismatchFor("", "2", "1970-W02")');
27 debug('Normal step values');
28 shouldBeTrue('stepMismatchFor("2010-W03", "2", "2010-W02")');
29 shouldBeFalse('stepMismatchFor("2010-W02", "2", "2010-W02")');
30 shouldBeFalse('stepMismatchFor("2010-W04", "2", "2010-W02")');
31 shouldBeTrue('stepMismatchFor("1800-W11", "3", "1800-W09")');
32 shouldBeFalse('stepMismatchFor("1800-W09", "3", "1800-W09")');
33 shouldBeFalse('stepMismatchFor("1800-W12", "3", "1800-W09")');
34 shouldBeTrue('stepMismatchFor("275760-W35", "3", "275760-W33")');
35 shouldBeFalse('stepMismatchFor("275760-W35", "2", "275760-W33")');
36 debug('Implicit step base');
37 shouldBeFalse('stepMismatchFor("1970-W01", "2", null)');
38 shouldBeTrue('stepMismatchFor("1970-W02", "2", null)');
39 shouldBeFalse('stepMismatchFor("1970-W03", "2", null)');
40 shouldBeTrue('stepMismatchFor("1970-W04", "2", null)');
41 debug('Fractional step values');
42 shouldBeFalse('stepMismatchFor("2010-W03", "0.1", "2010-W02")');
43 shouldBeFalse('stepMismatchFor("2010-W03", "1.1", "2010-W02")');
44 shouldBeTrue('stepMismatchFor("2010-W03", "1.9", "2010-W02")');
45 debug('Invalid or no step values');
46 shouldBeFalse('stepMismatchFor("2010-W03", null, "2010-W02")');
47 shouldBeFalse('stepMismatchFor("2010-W03", "-1", "2010-W02")');
48 shouldBeFalse('stepMismatchFor("2010-W03", "foo", "2010-W02")');
49 debug('Special step value');
50 shouldBeFalse('stepMismatchFor("2010-W03", "any", "2010-W02")');
51 debug('Disabled');
52 shouldBeFalse('stepMismatchFor("2010-W03", "2", "2010-W02", true)');
53 </script>
54 </body>
55 </html>