Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / number / number-commit-valid-only.html
blobbd793ec02334225349162fc678ceb15971fd26ab
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <script>
8 description('Type=number field should not accept invalid numbers though a user can type such strings');
10 var parent = document.createElement('div');
11 document.body.appendChild(parent);
12 parent.innerHTML = '<input type=number id=number value=256>';
14 var input = document.getElementById('number');
16 function checkIt(what, sample, expected)
18 input.focus();
19 document.execCommand("SelectAll");
20 document.execCommand("InsertText", false, sample);
21 input.blur();
22 debug('enter "' + sample + '" for ' + what);
23 shouldBeEqualToString('input.value', expected);
26 debug("\nNo restriction");
27 checkIt('noRange', "512", "512");
28 checkIt('typeMismatch', "+++", "");
29 checkIt('empty', "", "");
31 debug("\nmin/max/step");
32 input.setAttribute("min", "0");
33 input.setAttribute("max", "100");
34 input.setAttribute("step", "1");
35 checkIt("randerUnderflow", "-1", "-1");
36 checkIt("minimum", "0", "0");
37 checkIt("inRange", "25", "25");
38 checkIt("inRange", "50", "50");
39 checkIt("stepMismatch", "10.5", "10.5");
40 checkIt("maximum", "100", "100");
41 checkIt("rangeOverflow", "200", "200");
42 checkIt("typeMismatch", "abc", "");
43 checkIt("empty", "", ""); // empty
45 </script>
46 </body>
47 </html>