| OLD | NEW |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/js-test.js"></script> |
| 5 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <p id="description"></p> | 7 <p id="description"></p> |
| 8 <div id="console"></div> | 8 <div id="console"></div> |
| 9 <script> | 9 <script> |
| 10 description('Tests for tooLong flag with <input> elements.'); | 10 description('Tests for tooLong flag with <input> elements.'); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 document.execCommand('delete'); | 41 document.execCommand('delete'); |
| 42 shouldBeFalse('input.validity.tooLong'); | 42 shouldBeFalse('input.validity.tooLong'); |
| 43 | 43 |
| 44 debug(''); | 44 debug(''); |
| 45 debug('Sets a value via DOM property'); | 45 debug('Sets a value via DOM property'); |
| 46 input.maxLength = 3; | 46 input.maxLength = 3; |
| 47 input.value = 'abcde'; | 47 input.value = 'abcde'; |
| 48 shouldBeFalse('input.validity.tooLong'); | 48 shouldBeFalse('input.validity.tooLong'); |
| 49 | 49 |
| 50 debug(''); | 50 debug(''); |
| 51 debug('Disabled'); | 51 debug('Disabling makes the control valid'); |
| 52 input.disabled = true; | 52 input.focus(); |
| 53 shouldBeFalse('input.validity.tooLong'); | 53 input.setSelectionRange(5, 5); // Move the cursor at the end. |
| 54 input.disabled = false; | 54 document.execCommand('delete'); |
| 55 shouldBeTrue('input.validity.tooLong'); |
| 56 shouldBeFalse('input.disabled = true; input.validity.tooLong'); |
| 57 shouldBeTrue('input.disabled = false; input.validity.tooLong'); |
| 55 | 58 |
| 59 // FIXME: The grapheme test below doesn't do its job because initial value is |
| 60 // always valid. After making a modificaton to trigger validity check, one can |
| 61 // see that the test would fail, which possibly reveals a code issue. |
| 62 // https://code.google.com/p/chromium/issues/detail?id=421727 |
| 63 // Once this is figured out, implement a similar test in |
| 64 // ValidityState-tooShort-input.html |
| 56 debug(''); | 65 debug(''); |
| 57 debug('Grapheme length is not greater than maxLength though character length is
greater'); | 66 debug('Grapheme length is not greater than maxLength though character length is
greater'); |
| 58 // fancyX should be treated as 1 grapheme. | 67 // fancyX should be treated as 1 grapheme. |
| 59 // U+0305 COMBINING OVERLINE | 68 // U+0305 COMBINING OVERLINE |
| 60 // U+0332 COMBINING LOW LINE | 69 // U+0332 COMBINING LOW LINE |
| 61 var fancyX = "x\u0305\u0332"; | 70 var fancyX = "x\u0305\u0332"; |
| 62 input = document.createElement('input'); | 71 input = document.createElement('input'); |
| 63 document.body.appendChild(input); | 72 document.body.appendChild(input); |
| 64 input.value = fancyX; // 3 characters, 1 grapheme clusters. | 73 input.value = fancyX; // 3 characters, 1 grapheme clusters. |
| 65 input.maxLength = 1; | 74 input.maxLength = 1; |
| 66 shouldBeFalse('input.validity.tooLong'); | 75 shouldBeFalse('input.validity.tooLong'); |
| 67 | 76 |
| 68 debug(''); | 77 debug(''); |
| 69 debug('Change the type with a too long value'); | 78 debug('Change the type with a too long value'); |
| 70 input.maxLength = 3; | 79 input.maxLength = 3; |
| 71 input.value = 'abcde'; | 80 input.value = 'abcde'; |
| 72 input.type = 'search'; | 81 input.type = 'search'; |
| 73 input.focus(); | 82 input.focus(); |
| 74 input.setSelectionRange(5, 5); | 83 input.setSelectionRange(5, 5); |
| 75 document.execCommand('delete'); | 84 document.execCommand('delete'); |
| 76 shouldBeTrue('input.validity.tooLong'); | 85 shouldBeTrue('input.validity.tooLong'); |
| 77 shouldBeFalse('input.type = "number"; input.validity.tooLong'); | 86 shouldBeFalse('input.type = "number"; input.validity.tooLong'); |
| 87 input.type = "text"; |
| 88 |
| 89 debug(''); |
| 90 debug('minlength and maxlength together'); |
| 91 input.maxLength = 3; |
| 92 input.minLength = 3; |
| 93 input.value = 'abcde'; |
| 94 input.focus(); |
| 95 input.setSelectionRange(5, 5); |
| 96 document.execCommand('delete'); |
| 97 shouldBeTrue('input.validity.tooLong'); |
| 98 shouldBeFalse('input.validity.tooShort'); |
| 99 document.execCommand('delete'); |
| 100 shouldBeFalse('input.validity.tooLong'); |
| 101 shouldBeFalse('input.validity.tooShort'); |
| 102 document.execCommand('delete'); |
| 103 shouldBeFalse('input.validity.tooLong'); |
| 104 shouldBeTrue('input.validity.tooShort'); |
| 105 |
| 106 debug(''); |
| 107 debug('minlength and maxlength clashing'); |
| 108 input.setAttribute('maxlength', '2'); |
| 109 input.setAttribute('minlength', '4'); |
| 110 input.value = 'abcde'; |
| 111 input.focus(); |
| 112 input.setSelectionRange(5, 5); |
| 113 document.execCommand('delete'); |
| 114 shouldBeTrue('input.validity.tooLong'); |
| 115 shouldBeFalse('input.validity.tooShort'); |
| 116 document.execCommand('delete'); |
| 117 shouldBeTrue('input.validity.tooLong'); |
| 118 shouldBeTrue('input.validity.tooShort'); |
| 119 document.execCommand('delete'); |
| 120 shouldBeFalse('input.validity.tooLong'); |
| 121 shouldBeTrue('input.validity.tooShort'); |
| 122 document.execCommand('delete'); |
| 123 document.execCommand('delete'); |
| 124 shouldBeFalse('input.validity.tooLong'); |
| 125 shouldBeFalse('input.validity.tooShort'); |
| 126 |
| 78 </script> | 127 </script> |
| 79 </body> | 128 </body> |
| 80 </html> | 129 </html> |
| OLD | NEW |