Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / input-text-paste-maxlength.html
bloba09d09afe29291e55a0f598566e87efed128f7ce
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
10 <div id=container>
11 <input type="text" id="f" size="5" maxlength="4">
12 <input type="text" id="e" size="5" maxlength="4">
13 <input type="text" id="d" size="5">
14 <input type="text" id="c" size="5">
15 <input type="text" id="j" size="5" maxlength="4">
16 <input type="text" id="i" size="5" maxlength="4">
17 <input type="text" id="h" size="5">
18 <input type="text" id="g" size="5">
19 <input type="text" id="k-max5" size="5" maxlength="5">
20 <input type="text" id="l" size="5" maxlength="0">
21 <input type="text" id="m" size="5" maxlength="">
22 <input type="text" id="n" size="5" maxlength="invalid">
23 <input type="text" id="huge" size="5" maxlength="9999999999">
24 </div>
26 <script>
27 function domValueOf(id) {
28 return document.getElementById(id).value;
30 function visibleValueOf(id) {
31 var el = document.getElementById(id);
32 el.focus();
33 document.execCommand('SelectAll');
34 return document.getSelection().toString();
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";
41 debug("set value attribute that violates maxlength (with pasted value)");
42 document.getElementById("f").focus();
43 document.execCommand("InsertHTML", false, "123");
44 document.getElementById("f").setAttribute('value', '12345');
45 shouldBe("domValueOf('f')", "'123'"); // setAttribute() doesn't change the value because the value is dirty.
46 shouldBe("visibleValueOf('f')", "'123'");
48 debug("set value property that violates maxlength (with pasted value)");
49 document.getElementById("e").focus();
50 document.execCommand("InsertHTML", false, "123");
51 document.getElementById("e").value = '12345';
52 shouldBe("domValueOf('e')", "'12345'"); // Unlike setAttribute(), .value property changes the value.
53 shouldBe("visibleValueOf('e')", "'12345'");
55 debug("set maxlength attribute that is smaller than pasted value");
56 document.getElementById("d").focus();
57 document.execCommand("InsertHTML", false, "12345");
58 document.getElementById("d").setAttribute('maxlength', 4);
59 shouldBe("domValueOf('d')", "'12345'");
60 shouldBe("visibleValueOf('d')", "'12345'");
62 debug("set maxLength property that is smaller than pasted value");
63 document.getElementById("c").focus();
64 document.execCommand("InsertHTML", false, "12345");
65 document.getElementById("c").maxLength = 4;
66 shouldBe("domValueOf('c')", "'12345'");
67 shouldBe("visibleValueOf('c')", "'12345'");
69 debug("set value attribute that violates maxlength (with pasted value)");
70 document.getElementById("j").focus();
71 document.execCommand("InsertHTML", false, "123");
72 document.getElementById("j").setAttribute('value', '12' + fancyX + '45');
73 shouldBe("domValueOf('j')", "'123'");
74 shouldBe("visibleValueOf('j')", "'123'");
76 debug("set value property that violates maxlength (with pasted value)");
77 document.getElementById("i").focus();
78 document.execCommand("InsertHTML", false, "123");
79 document.getElementById("i").value = '12' + fancyX + '45';
80 shouldBe("domValueOf('i')", "'12' + fancyX + '45'");
81 shouldBe("visibleValueOf('i')", "'12' + fancyX + '45'");
83 debug("set maxlength attribute that is smaller than pasted value");
84 document.getElementById("h").focus();
85 document.execCommand("InsertHTML", false, "12x&#x305;&#x332;45");
86 document.getElementById("h").setAttribute('maxlength', 4);
87 shouldBe("domValueOf('h')", "'12' + fancyX + '45'");
88 shouldBe("visibleValueOf('h')", "'12' + fancyX + '45'");
90 debug("set maxLength property that is smaller than pasted value");
91 document.getElementById("g").focus();
92 document.execCommand("InsertHTML", false, "12x&#x305;&#x332;45");
93 document.getElementById("g").maxLength = 4;
94 shouldBe("domValueOf('g')", "'12' + fancyX + '45'");
95 shouldBe("visibleValueOf('g')", "'12' + fancyX + '45'");
97 debug("pasting too much text");
98 var target = document.getElementById("k-max5");
99 target.focus();
100 document.execCommand("InsertHTML", false, "12x&#x305;&#x332;45");
101 shouldBeEqualToString("domValueOf('k-max5')", "12" + fancyX);
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");
113 debug("pasting too much text with maxlength=0");
114 document.getElementById("l").focus();
115 document.execCommand("InsertHTML", false, "12x&#x305;&#x332;45");
116 shouldBe("domValueOf('l')", "''");
117 shouldBe("visibleValueOf('l')", "''");
119 debug("empty maxlength should be ignored.");
120 document.getElementById("m").focus();
121 document.execCommand("InsertHTML", false, "12x&#x305;&#x332;45");
122 shouldBe("domValueOf('m')", "'12' + fancyX + '45'");
123 shouldBe("visibleValueOf('m')", "'12' + fancyX + '45'");
125 debug("invalid maxlength should be ignored.");
126 document.getElementById("n").focus();
127 document.execCommand("InsertHTML", false, "12x&#x305;&#x332;45");
128 shouldBe("domValueOf('n')", "'12' + fancyX + '45'");
129 shouldBe("visibleValueOf('n')", "'12' + fancyX + '45'");
130 document.getElementById("huge").focus();
131 document.execCommand("InsertHTML", false, "12x&#x305;&#x332;45");
132 shouldBe("domValueOf('huge')", "'12' + fancyX + '45'");
133 shouldBe("visibleValueOf('huge')", "'12' + fancyX + '45'");
135 document.getElementById('container').innerHTML = '';
136 </script>
137 </body>
138 </html>