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="../../fast/js/resources/js-test-pre.js"></script> | 4 <script src="../../fast/js/resources/js-test-pre.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 HTMLTextAreaElement.maxLength behaviors.'); | 10 description('Tests for HTMLTextAreaElement.maxLength behaviors.'); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 // Confirms correct count for open consecutive linebreaks inputs. | 106 // Confirms correct count for open consecutive linebreaks inputs. |
107 createFocusedTextAreaWithMaxLength(6); | 107 createFocusedTextAreaWithMaxLength(6); |
108 document.execCommand('insertLineBreak'); | 108 document.execCommand('insertLineBreak'); |
109 document.execCommand('insertLineBreak'); | 109 document.execCommand('insertLineBreak'); |
110 document.execCommand('insertLineBreak'); | 110 document.execCommand('insertLineBreak'); |
111 document.execCommand('insertLineBreak'); | 111 document.execCommand('insertLineBreak'); |
112 shouldBe('textArea.value', '"\\n\\n\\n"'); | 112 shouldBe('textArea.value', '"\\n\\n\\n"'); |
113 | 113 |
114 // According to the HTML5 specification, maxLength is code-point length. | 114 // According to the HTML5 specification, maxLength is code-point length. |
115 // However WebKit handles it as grapheme length. | 115 // Blink follows it though WebKit handles it as grapheme length. |
116 | 116 |
117 // fancyX should be treated as 1 grapheme. | 117 // fancyX should be treated as 1 grapheme. |
118 var fancyX = "x\u0305\u0332";// + String.fromCharCode(0x305) + String.fromCharCo
de(0x332); | 118 var fancyX = "x\u0305\u0332";// + String.fromCharCode(0x305) + String.fromCharCo
de(0x332); |
119 // u10000 is one character consisted of a surrogate pair. | 119 // u10000 is one character consisted of a surrogate pair. |
120 var u10000 = "\ud800\udc00"; | 120 var u10000 = "\ud800\udc00"; |
121 | 121 |
122 // Inserts 5 code-points in UTF-16 | 122 debug('Inserts 2 normal characters + a combining letter with 3 code points into
a maxlength=3 element.') |
123 createFocusedTextAreaWithMaxLength(3); | 123 createFocusedTextAreaWithMaxLength(3); |
124 document.execCommand('insertText', false, 'AB' + fancyX); | 124 document.execCommand('insertText', false, 'AB' + fancyX); |
125 shouldBe('textArea.value', '"AB" + fancyX'); | 125 shouldBeEqualToString('textArea.value', 'ABx'); |
126 shouldBe('textArea.value.length', '5'); | 126 shouldBe('textArea.value.length', '3'); |
127 | 127 |
128 createFocusedTextAreaWithMaxLength(3); | 128 createFocusedTextAreaWithMaxLength(3); |
129 textArea.value = 'AB' + fancyX; | 129 textArea.value = 'AB' + fancyX; |
130 textArea.setSelectionRange(2, 5); // Select fancyX | 130 textArea.setSelectionRange(2, 5); // Select fancyX |
131 document.execCommand('insertText', false, 'CDE'); | 131 document.execCommand('insertText', false, 'CDE'); |
132 shouldBe('textArea.value', '"ABC"'); | 132 shouldBe('textArea.value', '"ABC"'); |
133 | 133 |
134 // Inserts 4 code-points in UTF-16 | 134 debug('Inserts 2 normal characters + one surrogate pair into a maxlength=3 eleme
nt'); |
135 createFocusedTextAreaWithMaxLength(3); | 135 createFocusedTextAreaWithMaxLength(3); |
136 document.execCommand('insertText', false, 'AB' + u10000); | 136 document.execCommand('insertText', false, 'AB' + u10000); |
137 shouldBe('textArea.value', '"AB" + u10000'); | 137 shouldBeEqualToString('textArea.value', 'AB'); |
138 shouldBe('textArea.value.length', '4'); | 138 shouldBe('textArea.value.length', '2'); |
139 | 139 |
140 createFocusedTextAreaWithMaxLength(3); | 140 createFocusedTextAreaWithMaxLength(3); |
141 textArea.value = 'AB' + u10000; | 141 textArea.value = 'AB' + u10000; |
142 textArea.setSelectionRange(2, 4); // Select u10000 | 142 textArea.setSelectionRange(2, 4); // Select u10000 |
143 document.execCommand('insertText', false, 'CDE'); | 143 document.execCommand('insertText', false, 'CDE'); |
144 shouldBe('textArea.value', '"ABC"'); | 144 shouldBe('textArea.value', '"ABC"'); |
145 | 145 |
146 // In the case maxlength=0 | 146 // In the case maxlength=0 |
147 createFocusedTextAreaWithMaxLength(0); | 147 createFocusedTextAreaWithMaxLength(0); |
148 textArea.value = ''; | 148 textArea.value = ''; |
149 document.execCommand('insertText', false, 'ABC'); | 149 document.execCommand('insertText', false, 'ABC'); |
150 shouldBe('textArea.value', '""'); | 150 shouldBe('textArea.value', '""'); |
151 | 151 |
152 // In the case maxlength='' | 152 // In the case maxlength='' |
153 createFocusedTextAreaWithMaxLength(''); | 153 createFocusedTextAreaWithMaxLength(''); |
154 textArea.value = ''; | 154 textArea.value = ''; |
155 document.execCommand('insertText', false, 'ABC'); | 155 document.execCommand('insertText', false, 'ABC'); |
156 shouldBe('textArea.value', '"ABC"'); | 156 shouldBe('textArea.value', '"ABC"'); |
157 | 157 |
158 // In the case maxlength='invalid' | 158 // In the case maxlength='invalid' |
159 createFocusedTextAreaWithMaxLength('invalid'); | 159 createFocusedTextAreaWithMaxLength('invalid'); |
160 textArea.value = ''; | 160 textArea.value = ''; |
161 document.execCommand('insertText', false, 'ABC'); | 161 document.execCommand('insertText', false, 'ABC'); |
162 shouldBe('textArea.value', '"ABC"'); | 162 shouldBe('textArea.value', '"ABC"'); |
163 </script> | 163 </script> |
164 <script src="../../fast/js/resources/js-test-post.js"></script> | 164 <script src="../../fast/js/resources/js-test-post.js"></script> |
165 </body> | 165 </body> |
166 </html> | 166 </html> |
OLD | NEW |