4 <script src=
"../../../resources/js-test.js"></script>
9 internals
.settings
.setLangAttributeAwareFormControlUIEnabled(true);
10 description('Test for validationMessage IDL attribute for <input type=number>');
11 var parent
= document
.createElement('div');
12 document
.body
.appendChild(parent
);
13 parent
.innerHTML
= '<input type=number id=number maxlength=1 pattern=x>';
14 var input
= document
.getElementById('number');
16 function testIt(value
, min
, max
, step
)
18 input
.setAttribute("max", max
);
19 input
.setAttribute("min", min
);
20 input
.setAttribute("step", step
);
21 input
.setAttribute("value", value
);
22 return input
.validationMessage
;
26 shouldBeEqualToString('testIt("", "", "")', '');
28 debug('Value missing')
29 input
.setAttribute("required", "");
30 shouldBeEqualToString('testIt("", "", "")', 'Please fill out this field.');
31 input
.removeAttribute("required");
33 debug('Type mismatch');
34 shouldBeEqualToString('testIt("foo", "", "")', '');
36 debug('Range overflow')
37 shouldBeEqualToString('testIt("200", "", "100")', 'Value must be less than or equal to 100.');
38 // The following tests might show English text + non-English numbers. It's
39 // expected and it never happens in products.
41 shouldBeEqualToString('testIt("200", "", "100.4")', 'Value must be less than or equal to 100,4.');
43 shouldBeEqualToString('testIt("200", "", "100")', 'Value must be less than or equal to \u0661\u0660\u0660.');
46 debug('Range underflow')
47 shouldBeEqualToString('testIt("10", "50", "100")', 'Value must be greater than or equal to 50.');
49 shouldBeEqualToString('testIt("10", "50", "100")', 'Value must be greater than or equal to \u0665\u0660.');
52 debug('Step mismatch')
53 shouldBeEqualToString('testIt("55", "0", "100", "10")', 'Please enter a valid value. The two nearest valid values are 50 and 60.');