4 <script src=
"../../../resources/js-test.js"></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
) {
17 input
.disabled
= !!disabled
;
18 return input
.validity
.stepMismatch
;
22 input
.type
= 'number';
23 debug('Empty values');
24 shouldBe('stepMismatchFor("", null, null)', 'false');
25 shouldBe('stepMismatchFor("", "1.0", "0.1")', 'false');
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');
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');
49 shouldBe('stepMismatchFor("5.005", "0.005", "4")', 'false');
51 shouldBe('stepMismatchFor("1", "2", "0", true)', 'false');