blob: 32beecaa4d2afdaa42e494d3b33572651a144c0f [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description('Test for validationMessage IDL attribute for &lt;input type=number>');
var parent = document.createElement('div');
document.body.appendChild(parent);
parent.innerHTML = '<input type=number id=number maxlength=1 pattern=x>';
var input = document.getElementById('number');
function testIt(value, min, max, step)
{
input.setAttribute("max", max);
input.setAttribute("min", min);
input.setAttribute("step", step);
input.setAttribute("value", value);
return input.validationMessage;
}
debug('No message')
shouldBeEqualToString('testIt("", "", "")', '');
debug('Value missing')
input.setAttribute("required", "");
shouldBeEqualToString('testIt("", "", "")', 'Fill out this field');
input.removeAttribute("required");
debug('Type mismatch');
shouldBeEqualToString('testIt("foo", "", "")', '');
debug('Range overflow')
shouldBeEqualToString('testIt("200", "", "100")', 'Value must be less than or equal to 100');
debug('Range underflow')
shouldBeEqualToString('testIt("10", "50", "100")', 'Value must be greater than or equal to 50');
debug('Step mismatch')
shouldBeEqualToString('testIt("55", "0", "100", "10")', 'Enter a valid value');
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>