| 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 <script src="resources/common.js"></script> | 5 <script src="resources/common.js"></script> |
| 6 </head> | 6 </head> |
| 7 <body> | 7 <body> |
| 8 <p id="description"></p> | 8 <p id="description"></p> |
| 9 <div id="console"></div> | 9 <div id="console"></div> |
| 10 <script> | 10 <script> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 shouldBeFalse('input.validity.tooShort'); | 28 shouldBeFalse('input.validity.tooShort'); |
| 29 | 29 |
| 30 debug(''); | 30 debug(''); |
| 31 debug('Dirty value and longer than minLength'); | 31 debug('Dirty value and longer than minLength'); |
| 32 input = document.createElement('input'); | 32 input = document.createElement('input'); |
| 33 document.body.appendChild(input); | 33 document.body.appendChild(input); |
| 34 input.setAttribute('value', 'ab'); | 34 input.setAttribute('value', 'ab'); |
| 35 input.minLength = 3; | 35 input.minLength = 3; |
| 36 input.focus(); | 36 input.focus(); |
| 37 input.setSelectionRange(2, 2); // Move the cursor at the end. | 37 input.setSelectionRange(2, 2); // Move the cursor at the end. |
| 38 eventSender.keyDown('backspace'); | 38 eventSender.keyDown('Backspace'); |
| 39 shouldBe('input.value.length', '1'); | 39 shouldBe('input.value.length', '1'); |
| 40 shouldBeTrue('input.validity.tooShort'); | 40 shouldBeTrue('input.validity.tooShort'); |
| 41 // Make the value empty, which means valid. | 41 // Make the value empty, which means valid. |
| 42 eventSender.keyDown('backspace'); | 42 eventSender.keyDown('Backspace'); |
| 43 shouldBe('input.value.length', '0'); | 43 shouldBe('input.value.length', '0'); |
| 44 shouldBeFalse('input.validity.tooShort'); | 44 shouldBeFalse('input.validity.tooShort'); |
| 45 sendString('ab'); | 45 sendString('ab'); |
| 46 shouldBe('input.value.length', '2'); | 46 shouldBe('input.value.length', '2'); |
| 47 shouldBeTrue('input.validity.tooShort'); | 47 shouldBeTrue('input.validity.tooShort'); |
| 48 // Make the value >=minLength. | 48 // Make the value >=minLength. |
| 49 sendString('c'); | 49 sendString('c'); |
| 50 shouldBe('input.value.length', '3'); | 50 shouldBe('input.value.length', '3'); |
| 51 shouldBeFalse('input.validity.tooShort'); | 51 shouldBeFalse('input.validity.tooShort'); |
| 52 | 52 |
| 53 debug(''); | 53 debug(''); |
| 54 debug('Sets a value via DOM property'); | 54 debug('Sets a value via DOM property'); |
| 55 input.minLength = 3; | 55 input.minLength = 3; |
| 56 input.value = 'ab'; | 56 input.value = 'ab'; |
| 57 shouldBeFalse('input.validity.tooShort'); | 57 shouldBeFalse('input.validity.tooShort'); |
| 58 | 58 |
| 59 debug(''); | 59 debug(''); |
| 60 debug('Disabling makes the control valid'); | 60 debug('Disabling makes the control valid'); |
| 61 input.focus(); | 61 input.focus(); |
| 62 input.setSelectionRange(2, 2); | 62 input.setSelectionRange(2, 2); |
| 63 eventSender.keyDown('backspace'); | 63 eventSender.keyDown('Backspace'); |
| 64 shouldBeTrue('input.validity.tooShort'); | 64 shouldBeTrue('input.validity.tooShort'); |
| 65 shouldBeFalse('input.disabled = true; input.validity.tooShort'); | 65 shouldBeFalse('input.disabled = true; input.validity.tooShort'); |
| 66 shouldBeTrue('input.disabled = false; input.validity.tooShort'); | 66 shouldBeTrue('input.disabled = false; input.validity.tooShort'); |
| 67 | 67 |
| 68 debug(''); | 68 debug(''); |
| 69 debug('Change the type with a too long value'); | 69 debug('Change the type with a too long value'); |
| 70 input.minLength = 3; | 70 input.minLength = 3; |
| 71 input.value = 'a'; | 71 input.value = 'a'; |
| 72 input.type = 'search'; | 72 input.type = 'search'; |
| 73 input.focus(); | 73 input.focus(); |
| 74 input.setSelectionRange(1, 1); | 74 input.setSelectionRange(1, 1); |
| 75 sendString('b'); | 75 sendString('b'); |
| 76 shouldBeTrue('input.validity.tooShort'); | 76 shouldBeTrue('input.validity.tooShort'); |
| 77 shouldBeFalse('input.type = "number"; input.validity.tooShort'); | 77 shouldBeFalse('input.type = "number"; input.validity.tooShort'); |
| 78 | 78 |
| 79 debug(''); | 79 debug(''); |
| 80 debug('Grapheme length is shorter than minLength though character length is grea
ter'); | 80 debug('Grapheme length is shorter than minLength though character length is grea
ter'); |
| 81 // fancyX should be treated as 1 grapheme. | 81 // fancyX should be treated as 1 grapheme. |
| 82 // U+0305 COMBINING OVERLINE | 82 // U+0305 COMBINING OVERLINE |
| 83 // U+0332 COMBINING LOW LINE | 83 // U+0332 COMBINING LOW LINE |
| 84 var fancyX = 'x\u0305\u0332'; | 84 var fancyX = 'x\u0305\u0332'; |
| 85 input = document.createElement('input'); | 85 input = document.createElement('input'); |
| 86 document.body.appendChild(input); | 86 document.body.appendChild(input); |
| 87 input.value = fancyX + 'A'; // 4 characters, 2 grapheme cluster. | 87 input.value = fancyX + 'A'; // 4 characters, 2 grapheme cluster. |
| 88 input.minLength = 2; | 88 input.minLength = 2; |
| 89 input.focus(); | 89 input.focus(); |
| 90 shouldBeFalse('input.validity.tooShort'); | 90 shouldBeFalse('input.validity.tooShort'); |
| 91 eventSender.keyDown('backspace'); // Make the value dirty, 1 grapheme remains. | 91 eventSender.keyDown('Backspace'); // Make the value dirty, 1 grapheme remains. |
| 92 // Not too short because there are three characters. | 92 // Not too short because there are three characters. |
| 93 shouldBe('input.value.length', '3'); | 93 shouldBe('input.value.length', '3'); |
| 94 shouldBeFalse('input.validity.tooShort'); | 94 shouldBeFalse('input.validity.tooShort'); |
| 95 input.remove(); | 95 input.remove(); |
| 96 </script> | 96 </script> |
| 97 </body> | 97 </body> |
| 98 </html> | 98 </html> |
| OLD | NEW |