Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / week / ValidityState-rangeOverflow-week.html
blobfd7a9c23658e52667c767eed4c2d425073c4a1e6
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('This test aims to check for rangeOverflow flag with week input fields');
12 var input = document.createElement('input');
14 function checkOverflow(value, max, disabled)
16 input.value = value;
17 input.max = max;
18 input.disabled = !!disabled;
19 var overflow = input.validity.rangeOverflow;
20 var resultText = 'The value "' + input.value + '" ' +
21 (overflow ? 'overflows' : 'doesn\'t overflow') +
22 ' the maximum value "' + input.max + '"' + (disabled ? ' when disabled.' : '.');
23 if (overflow)
24 testPassed(resultText);
25 else
26 testFailed(resultText);
29 function checkNotOverflow(value, max, disabled, sanitized)
31 input.value = value;
32 input.max = max;
33 input.disabled = !!disabled;
34 var overflow = input.validity.rangeOverflow;
35 var resultText = 'The value "' + input.value + '" ' +
36 (sanitized ? 'sanitized from "' + value + '" ' : '') +
37 (overflow ? 'overflows' : 'doesn\'t overflow') +
38 ' the maximum value "' + input.max + '"' + (disabled ? ' when disabled.' : '.');
39 if (overflow)
40 testFailed(resultText);
41 else
42 testPassed(resultText);
45 function checkSanitizedValueNotOverflow(value, max, disabled)
47 // For date types, invalid values are sanitized to "".
48 checkNotOverflow(value, max, disabled, true);
51 input.type = 'week';
52 input.min = '';
53 // No overflow cases
54 checkNotOverflow('2010-W01', null);
55 checkNotOverflow('2010-W01', '');
56 checkNotOverflow('2010-W01', 'foo');
57 checkNotOverflow('2010-W01', '2010-W01');
58 checkNotOverflow('2010-W01', '2010-W02');
59 checkNotOverflow('2010-W01', '2011-W01');
60 checkSanitizedValueNotOverflow('foo', '2011-W01');
61 checkNotOverflow('2010-W01', '0000-W01'); // Invalid max value.
63 // Overflow cases
64 checkOverflow('2010-W01', '1582-W01');
65 checkOverflow('2010-W01', '2009-W12');
66 checkOverflow('9999-W01', '2010-W12');
67 input.min = '2010-W02'; // value < min && value > max
68 checkOverflow('2010-W01', '2009-W50');
70 // Disabled
71 checkNotOverflow('9999-W01', '2010-W12', true);
72 </script>
73 </body>
74 </html>