1 description('This test aims to check for typeMismatch flag with type=number input fields');
3 var i = document.createElement('input');
6 function check(value, disabled)
9 i.disabled = !!disabled;
10 var mismatch = i.validity.typeMismatch;
11 var resultText = '"' + value + '" is ' + (mismatch ? 'an invalid' : 'a valid') + ' number' + (disabled ? ' when disabled.' : '.');
13 testPassed(resultText);
15 testFailed(resultText);
18 function checkSanitization(value, expectedValue)
21 if (i.validity.typeMismatch) {
22 testFailed('"' + value + '" made typeMismatch true.');
23 } else if (i.value != expectedValue) {
24 testFailed('"' + value + '" was sanitized to "' + i.value + '". It should be ' + expectedValue);
26 testPassed('"' + value + '" was sanitized to "' + i.value + '".');
41 check('12345678901234567890123456789012345678901234567890');
42 check('0.12345678901234567890123456789012345678901234567890');
45 checkSanitization('abc', '');
46 checkSanitization('0xff', '');
48 checkSanitization('+1', '');
49 checkSanitization(' 10', '');
50 checkSanitization('10 ', '');
51 checkSanitization('1,2', '');
52 checkSanitization('1E', '');
53 checkSanitization('NaN', '');
54 checkSanitization('nan', '');
55 checkSanitization('Inf', '');
56 checkSanitization('inf', '');
57 checkSanitization('Infinity', '');
58 checkSanitization('infinity', '');
60 // Assume empty string as valid.
64 checkSanitization('1.2E65535', '');
66 // The spec doesn't allow, but our implementation does.
71 check('invalid', true);