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 | 9 |
10 <div id=container> | 10 <div id=container> |
11 <input type="text" id="f" size="5" maxlength="4"> | 11 <input type="text" id="f" size="5" maxlength="4"> |
12 <input type="text" id="e" size="5" maxlength="4"> | 12 <input type="text" id="e" size="5" maxlength="4"> |
13 <input type="text" id="d" size="5"> | 13 <input type="text" id="d" size="5"> |
14 <input type="text" id="c" size="5"> | 14 <input type="text" id="c" size="5"> |
15 <input type="text" id="j" size="5" maxlength="4"> | 15 <input type="text" id="j" size="5" maxlength="4"> |
16 <input type="text" id="i" size="5" maxlength="4"> | 16 <input type="text" id="i" size="5" maxlength="4"> |
17 <input type="text" id="h" size="5"> | 17 <input type="text" id="h" size="5"> |
18 <input type="text" id="g" size="5"> | 18 <input type="text" id="g" size="5"> |
19 <input type="text" id="k" size="5" maxlength="4"> | 19 <input type="text" id="k-max5" size="5" maxlength="5"> |
20 <input type="text" id="l" size="5" maxlength="0"> | 20 <input type="text" id="l" size="5" maxlength="0"> |
21 <input type="text" id="m" size="5" maxlength=""> | 21 <input type="text" id="m" size="5" maxlength=""> |
22 <input type="text" id="n" size="5" maxlength="invalid"> | 22 <input type="text" id="n" size="5" maxlength="invalid"> |
23 <input type="text" id="huge" size="5" maxlength="9999999999"> | 23 <input type="text" id="huge" size="5" maxlength="9999999999"> |
24 </div> | 24 </div> |
25 | 25 |
26 <script> | 26 <script> |
27 function domValueOf(id) { | 27 function domValueOf(id) { |
28 return document.getElementById(id).value; | 28 return document.getElementById(id).value; |
29 } | 29 } |
30 function visibleValueOf(id) { | 30 function visibleValueOf(id) { |
31 var el = document.getElementById(id); | 31 var el = document.getElementById(id); |
32 el.focus(); | 32 el.focus(); |
33 document.execCommand('SelectAll'); | 33 document.execCommand('SelectAll'); |
34 return document.getSelection().toString(); | 34 return document.getSelection().toString(); |
35 } | 35 } |
36 | 36 |
37 var fancyX = "x" + String.fromCharCode(0x305) + String.fromCharCode(0x332); | 37 var fancyX = "x" + String.fromCharCode(0x305) + String.fromCharCode(0x332); |
| 38 // u10000 is one character consisted of a surrogate pair. |
| 39 var u10000 = "\ud800\udc00"; |
38 | 40 |
39 debug("set value attribute that violates maxlength (with pasted value)"); | 41 debug("set value attribute that violates maxlength (with pasted value)"); |
40 document.getElementById("f").focus(); | 42 document.getElementById("f").focus(); |
41 document.execCommand("InsertHTML", false, "123"); | 43 document.execCommand("InsertHTML", false, "123"); |
42 document.getElementById("f").setAttribute('value', '12345'); | 44 document.getElementById("f").setAttribute('value', '12345'); |
43 shouldBe("domValueOf('f')", "'123'"); // setAttribute() doesn't change the valu
e because the value is dirty. | 45 shouldBe("domValueOf('f')", "'123'"); // setAttribute() doesn't change the valu
e because the value is dirty. |
44 shouldBe("visibleValueOf('f')", "'123'"); | 46 shouldBe("visibleValueOf('f')", "'123'"); |
45 | 47 |
46 debug("set value property that violates maxlength (with pasted value)"); | 48 debug("set value property that violates maxlength (with pasted value)"); |
47 document.getElementById("e").focus(); | 49 document.getElementById("e").focus(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 shouldBe("visibleValueOf('h')", "'12' + fancyX + '45'"); | 88 shouldBe("visibleValueOf('h')", "'12' + fancyX + '45'"); |
87 | 89 |
88 debug("set maxLength property that is smaller than pasted value"); | 90 debug("set maxLength property that is smaller than pasted value"); |
89 document.getElementById("g").focus(); | 91 document.getElementById("g").focus(); |
90 document.execCommand("InsertHTML", false, "12x̲̅45"); | 92 document.execCommand("InsertHTML", false, "12x̲̅45"); |
91 document.getElementById("g").maxLength = 4; | 93 document.getElementById("g").maxLength = 4; |
92 shouldBe("domValueOf('g')", "'12' + fancyX + '45'"); | 94 shouldBe("domValueOf('g')", "'12' + fancyX + '45'"); |
93 shouldBe("visibleValueOf('g')", "'12' + fancyX + '45'"); | 95 shouldBe("visibleValueOf('g')", "'12' + fancyX + '45'"); |
94 | 96 |
95 debug("pasting too much text"); | 97 debug("pasting too much text"); |
96 document.getElementById("k").focus(); | 98 var target = document.getElementById("k-max5"); |
| 99 target.focus(); |
97 document.execCommand("InsertHTML", false, "12x̲̅45"); | 100 document.execCommand("InsertHTML", false, "12x̲̅45"); |
98 shouldBe("domValueOf('k')", "'12' + fancyX + '4'"); | 101 shouldBeEqualToString("domValueOf('k-max5')", "12" + fancyX); |
99 shouldBe("visibleValueOf('k')", "'12' + fancyX + '4'"); | 102 shouldBeEqualToString("visibleValueOf('k-max5')", "12" + fancyX); |
| 103 target.value = ""; |
| 104 document.execCommand("InsertHTML", false, "123" + u10000); |
| 105 shouldBeEqualToString("domValueOf('k-max5')", "123" + u10000); |
| 106 shouldBeEqualToString("visibleValueOf('k-max5')", "123" + u10000); |
| 107 target.value = ""; |
| 108 document.execCommand("InsertHTML", false, "1234" + u10000); |
| 109 shouldBeEqualToString("domValueOf('k-max5')", "1234"); |
| 110 shouldBeEqualToString("visibleValueOf('k-max5')", "1234"); |
| 111 |
100 | 112 |
101 debug("pasting too much text with maxlength=0"); | 113 debug("pasting too much text with maxlength=0"); |
102 document.getElementById("l").focus(); | 114 document.getElementById("l").focus(); |
103 document.execCommand("InsertHTML", false, "12x̲̅45"); | 115 document.execCommand("InsertHTML", false, "12x̲̅45"); |
104 shouldBe("domValueOf('l')", "''"); | 116 shouldBe("domValueOf('l')", "''"); |
105 shouldBe("visibleValueOf('l')", "''"); | 117 shouldBe("visibleValueOf('l')", "''"); |
106 | 118 |
107 debug("empty maxlength should be ignored."); | 119 debug("empty maxlength should be ignored."); |
108 document.getElementById("m").focus(); | 120 document.getElementById("m").focus(); |
109 document.execCommand("InsertHTML", false, "12x̲̅45"); | 121 document.execCommand("InsertHTML", false, "12x̲̅45"); |
110 shouldBe("domValueOf('m')", "'12' + fancyX + '45'"); | 122 shouldBe("domValueOf('m')", "'12' + fancyX + '45'"); |
111 shouldBe("visibleValueOf('m')", "'12' + fancyX + '45'"); | 123 shouldBe("visibleValueOf('m')", "'12' + fancyX + '45'"); |
112 | 124 |
113 debug("invalid maxlength should be ignored."); | 125 debug("invalid maxlength should be ignored."); |
114 document.getElementById("n").focus(); | 126 document.getElementById("n").focus(); |
115 document.execCommand("InsertHTML", false, "12x̲̅45"); | 127 document.execCommand("InsertHTML", false, "12x̲̅45"); |
116 shouldBe("domValueOf('n')", "'12' + fancyX + '45'"); | 128 shouldBe("domValueOf('n')", "'12' + fancyX + '45'"); |
117 shouldBe("visibleValueOf('n')", "'12' + fancyX + '45'"); | 129 shouldBe("visibleValueOf('n')", "'12' + fancyX + '45'"); |
118 document.getElementById("huge").focus(); | 130 document.getElementById("huge").focus(); |
119 document.execCommand("InsertHTML", false, "12x̲̅45"); | 131 document.execCommand("InsertHTML", false, "12x̲̅45"); |
120 shouldBe("domValueOf('huge')", "'12' + fancyX + '45'"); | 132 shouldBe("domValueOf('huge')", "'12' + fancyX + '45'"); |
121 shouldBe("visibleValueOf('huge')", "'12' + fancyX + '45'"); | 133 shouldBe("visibleValueOf('huge')", "'12' + fancyX + '45'"); |
122 | 134 |
123 document.getElementById('container').innerHTML = ''; | 135 document.getElementById('container').innerHTML = ''; |
124 </script> | 136 </script> |
125 <script src="../../fast/js/resources/js-test-post.js"></script> | 137 <script src="../../fast/js/resources/js-test-post.js"></script> |
126 </body> | 138 </body> |
127 </html> | 139 </html> |
OLD | NEW |