Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / number / number-validation-message.html
blob0edc95ab42daaa24bd524a094dc2fdc325ae5621
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <script>
8 if (window.internals)
9 internals.settings.setLangAttributeAwareFormControlUIEnabled(true);
10 description('Test for validationMessage IDL attribute for &lt;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;
25 debug('No message')
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.
40 input.lang = 'fr-fr';
41 shouldBeEqualToString('testIt("200", "", "100.4")', 'Value must be less than or equal to 100,4.');
42 input.lang = 'ar-eg';
43 shouldBeEqualToString('testIt("200", "", "100")', 'Value must be less than or equal to \u0661\u0660\u0660.');
44 input.lang = 'en-us';
46 debug('Range underflow')
47 shouldBeEqualToString('testIt("10", "50", "100")', 'Value must be greater than or equal to 50.');
48 input.lang = 'ar-eg';
49 shouldBeEqualToString('testIt("10", "50", "100")', 'Value must be greater than or equal to \u0665\u0660.');
50 input.lang = 'en-us';
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.');
55 </script>
56 </body>
57 </html>