Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/forms/ValidityState-tooLong-textarea.html

Issue 2100243002: Remove non-standardize key code names from event_sender. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix inspector tests that were missed by sed Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 &lt;textarea> elements.'); 10 description('Tests for tooLong flag with &lt;textarea> elements.');
(...skipping 16 matching lines...) Expand all
27 shouldBeFalse('textarea.validity.tooLong'); 27 shouldBeFalse('textarea.validity.tooLong');
28 28
29 debug(''); 29 debug('');
30 debug('Dirty value and longer than maxLength'); 30 debug('Dirty value and longer than maxLength');
31 textarea = document.createElement('textarea'); 31 textarea = document.createElement('textarea');
32 document.body.appendChild(textarea); 32 document.body.appendChild(textarea);
33 textarea.defaultValue = 'abcde'; 33 textarea.defaultValue = 'abcde';
34 textarea.maxLength = 3; 34 textarea.maxLength = 3;
35 textarea.focus(); 35 textarea.focus();
36 textarea.setSelectionRange(5, 5); // Move the cursor at the end. 36 textarea.setSelectionRange(5, 5); // Move the cursor at the end.
37 eventSender.keyDown('backspace'); 37 eventSender.keyDown('Backspace');
38 shouldBe('textarea.value.length', '4'); 38 shouldBe('textarea.value.length', '4');
39 shouldBeTrue('textarea.validity.tooLong'); 39 shouldBeTrue('textarea.validity.tooLong');
40 // Make the value <=maxLength. 40 // Make the value <=maxLength.
41 eventSender.keyDown('backspace'); 41 eventSender.keyDown('Backspace');
42 shouldBeFalse('textarea.validity.tooLong'); 42 shouldBeFalse('textarea.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 textarea = document.createElement('textarea'); 46 textarea = document.createElement('textarea');
47 document.body.appendChild(textarea); 47 document.body.appendChild(textarea);
48 textarea.maxLength = 3; 48 textarea.maxLength = 3;
49 textarea.value = 'abcde'; 49 textarea.value = 'abcde';
50 shouldBeFalse('textarea.validity.tooLong'); 50 shouldBeFalse('textarea.validity.tooLong');
51 51
52 debug(''); 52 debug('');
53 debug('Disabling makes the control valid'); 53 debug('Disabling makes the control valid');
54 textarea.focus(); 54 textarea.focus();
55 textarea.setSelectionRange(5, 5); // Move the cursor at the end. 55 textarea.setSelectionRange(5, 5); // Move the cursor at the end.
56 eventSender.keyDown('backspace'); 56 eventSender.keyDown('Backspace');
57 shouldBeTrue('textarea.validity.tooLong'); 57 shouldBeTrue('textarea.validity.tooLong');
58 shouldBeFalse('textarea.disabled = true; textarea.validity.tooLong'); 58 shouldBeFalse('textarea.disabled = true; textarea.validity.tooLong');
59 shouldBeTrue('textarea.disabled = false; textarea.validity.tooLong'); 59 shouldBeTrue('textarea.disabled = false; textarea.validity.tooLong');
60 60
61 debug(''); 61 debug('');
62 debug('Grapheme length is not greater than maxLength though character length is greater'); 62 debug('Grapheme length is not greater than maxLength though character length is greater');
63 // fancyX should be treated as 1 grapheme. 63 // fancyX should be treated as 1 grapheme.
64 // U+0305 COMBINING OVERLINE 64 // U+0305 COMBINING OVERLINE
65 // U+0332 COMBINING LOW LINE 65 // U+0332 COMBINING LOW LINE
66 var fancyX = "x\u0305\u0332"; 66 var fancyX = "x\u0305\u0332";
67 textarea = document.createElement('textarea'); 67 textarea = document.createElement('textarea');
68 document.body.appendChild(textarea); 68 document.body.appendChild(textarea);
69 textarea.value = fancyX + 'A'; // 4 characters, 2 grapheme cluster. 69 textarea.value = fancyX + 'A'; // 4 characters, 2 grapheme cluster.
70 textarea.maxLength = 1; 70 textarea.maxLength = 1;
71 textarea.focus(); 71 textarea.focus();
72 shouldBeFalse('textarea.validity.tooLong'); 72 shouldBeFalse('textarea.validity.tooLong');
73 eventSender.keyDown('backspace'); // Make the value dirty, 1 grapheme remains. 73 eventSender.keyDown('Backspace'); // Make the value dirty, 1 grapheme remains.
74 // Too long because there are three characters. 74 // Too long because there are three characters.
75 shouldBe('textarea.value.length', '3'); 75 shouldBe('textarea.value.length', '3');
76 shouldBeTrue('textarea.validity.tooLong'); 76 shouldBeTrue('textarea.validity.tooLong');
77 77
78 debug(''); 78 debug('');
79 debug('A value set by resetting a form doesn\'t make tooLong true.'); 79 debug('A value set by resetting a form doesn\'t make tooLong true.');
80 // Make a dirty textarea. 80 // Make a dirty textarea.
81 var parent = document.createElement('div'); 81 var parent = document.createElement('div');
82 document.body.appendChild(parent); 82 document.body.appendChild(parent);
83 parent.innerHTML = '<form><textarea maxlength=2>abcdef</textarea></form>'; 83 parent.innerHTML = '<form><textarea maxlength=2>abcdef</textarea></form>';
84 textarea = parent.firstChild.firstChild; 84 textarea = parent.firstChild.firstChild;
85 textarea.focus(); 85 textarea.focus();
86 textarea.setSelectionRange(6, 6); 86 textarea.setSelectionRange(6, 6);
87 eventSender.keyDown('backspace'); 87 eventSender.keyDown('Backspace');
88 shouldBeTrue('textarea.validity.tooLong'); 88 shouldBeTrue('textarea.validity.tooLong');
89 parent.firstChild.reset(); 89 parent.firstChild.reset();
90 shouldBe('textarea.value', '"abcdef"'); 90 shouldBe('textarea.value', '"abcdef"');
91 shouldBeFalse('textarea.validity.tooLong'); 91 shouldBeFalse('textarea.validity.tooLong');
92 92
93 debug(''); 93 debug('');
94 debug('A value set by a child node change doesn\'t make tooLong true.'); 94 debug('A value set by a child node change doesn\'t make tooLong true.');
95 parent.innerHTML = '<textarea maxlength=2>abc</textarea>'; 95 parent.innerHTML = '<textarea maxlength=2>abc</textarea>';
96 textarea = parent.firstChild; 96 textarea = parent.firstChild;
97 shouldBeFalse('textarea.validity.tooLong'); 97 shouldBeFalse('textarea.validity.tooLong');
98 parent.firstChild.innerHTML = 'abcdef'; 98 parent.firstChild.innerHTML = 'abcdef';
99 shouldBe('textarea.value', '"abcdef"'); 99 shouldBe('textarea.value', '"abcdef"');
100 shouldBeFalse('textarea.validity.tooLong'); 100 shouldBeFalse('textarea.validity.tooLong');
101 101
102 debug(''); 102 debug('');
103 debug('minlength and maxlength together'); 103 debug('minlength and maxlength together');
104 textarea.maxLength = 3; 104 textarea.maxLength = 3;
105 textarea.minLength = 3; 105 textarea.minLength = 3;
106 textarea.value = 'abcde'; 106 textarea.value = 'abcde';
107 textarea.focus(); 107 textarea.focus();
108 textarea.setSelectionRange(5, 5); 108 textarea.setSelectionRange(5, 5);
109 eventSender.keyDown('backspace'); 109 eventSender.keyDown('Backspace');
110 shouldBeTrue('textarea.validity.tooLong'); 110 shouldBeTrue('textarea.validity.tooLong');
111 shouldBeFalse('textarea.validity.tooShort'); 111 shouldBeFalse('textarea.validity.tooShort');
112 eventSender.keyDown('backspace'); 112 eventSender.keyDown('Backspace');
113 shouldBeFalse('textarea.validity.tooLong'); 113 shouldBeFalse('textarea.validity.tooLong');
114 shouldBeFalse('textarea.validity.tooShort'); 114 shouldBeFalse('textarea.validity.tooShort');
115 eventSender.keyDown('backspace'); 115 eventSender.keyDown('Backspace');
116 shouldBeFalse('textarea.validity.tooLong'); 116 shouldBeFalse('textarea.validity.tooLong');
117 shouldBeTrue('textarea.validity.tooShort'); 117 shouldBeTrue('textarea.validity.tooShort');
118 118
119 debug(''); 119 debug('');
120 debug('minlength and maxlength clashing'); 120 debug('minlength and maxlength clashing');
121 textarea.setAttribute('maxlength', '2'); 121 textarea.setAttribute('maxlength', '2');
122 textarea.setAttribute('minlength', '4'); 122 textarea.setAttribute('minlength', '4');
123 textarea.value = 'abcde'; 123 textarea.value = 'abcde';
124 textarea.focus(); 124 textarea.focus();
125 textarea.setSelectionRange(5, 5); 125 textarea.setSelectionRange(5, 5);
126 eventSender.keyDown('backspace'); 126 eventSender.keyDown('Backspace');
127 shouldBeTrue('textarea.validity.tooLong'); 127 shouldBeTrue('textarea.validity.tooLong');
128 shouldBeFalse('textarea.validity.tooShort'); 128 shouldBeFalse('textarea.validity.tooShort');
129 eventSender.keyDown('backspace'); 129 eventSender.keyDown('Backspace');
130 shouldBeTrue('textarea.validity.tooLong'); 130 shouldBeTrue('textarea.validity.tooLong');
131 shouldBeTrue('textarea.validity.tooShort'); 131 shouldBeTrue('textarea.validity.tooShort');
132 eventSender.keyDown('backspace'); 132 eventSender.keyDown('Backspace');
133 shouldBeFalse('textarea.validity.tooLong'); 133 shouldBeFalse('textarea.validity.tooLong');
134 shouldBeTrue('textarea.validity.tooShort'); 134 shouldBeTrue('textarea.validity.tooShort');
135 eventSender.keyDown('backspace'); 135 eventSender.keyDown('Backspace');
136 eventSender.keyDown('backspace'); 136 eventSender.keyDown('Backspace');
137 shouldBeFalse('textarea.validity.tooLong'); 137 shouldBeFalse('textarea.validity.tooLong');
138 shouldBeFalse('textarea.validity.tooShort'); 138 shouldBeFalse('textarea.validity.tooShort');
139 139
140 </script> 140 </script>
141 </body> 141 </body>
142 </html> 142 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698