Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / number / number-validity-stepmismatch.html
blob2e72bd6042e263d4023c1451d4e5ad72b57fc919
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <script>
8 description('Check stepMismatch results for number type');
10 var input = document.createElement('input');
11 document.body.appendChild(input);
13 function stepMismatchFor(value, step, min, disabled) {
14 input.min = min;
15 input.step = step;
16 input.value = value;
17 input.disabled = !!disabled;
18 return input.validity.stepMismatch;
21 debug('Number type');
22 input.type = 'number';
23 debug('Empty values');
24 shouldBe('stepMismatchFor("", null, null)', 'false');
25 shouldBe('stepMismatchFor("", "1.0", "0.1")', 'false');
26 debug('Integers');
27 shouldBe('stepMismatchFor("1", "2", "0")', 'true');
28 shouldBe('stepMismatchFor("-3", "2", "-4")', 'true');
29 shouldBe('input.max = "5"; stepMismatchFor("5", "3", "0")', 'true');
30 shouldBe('input.value', '"5"');
31 debug('Invalid step values');
32 input.max = '';
33 shouldBe('stepMismatchFor("-3", "-2", "-4")', 'false');
34 shouldBe('stepMismatchFor("-3", null, "-4")', 'false');
35 shouldBe('stepMismatchFor("-3", undefined, "-4")', 'false');
36 debug('Huge numbers and small step; uncomparable');
37 shouldBe('stepMismatchFor("3.40282347e+38", "3", "")', 'false');
38 shouldBe('stepMismatchFor("3.40282346e+38", "3", "")', 'false');
39 shouldBe('stepMismatchFor("3.40282345e+38", "3", "")', 'false');
40 debug('Huge numbers and huge step');
41 shouldBe('stepMismatchFor("3.20e+38", "0.20e+38", "")', 'false');
42 shouldBe('stepMismatchFor("3.20e+38", "0.22e+38", "")', 'true');
43 debug('Fractional numbers');
44 shouldBe('stepMismatchFor("0.9", "0.1", "")', 'false');
45 shouldBe('stepMismatchFor("0.9", "0.1000001", "")', 'true');
46 shouldBe('stepMismatchFor("0.9", "0.1000000000000001", "")', 'false');
47 shouldBe('stepMismatchFor("1.0", "0.3333333333333333", "")', 'false');
48 debug('Rounding');
49 shouldBe('stepMismatchFor("5.005", "0.005", "4")', 'false');
50 debug('Disabled');
51 shouldBe('stepMismatchFor("1", "2", "0", true)', 'false');
52 </script>
53 </body>
54 </html>