1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../../resources/js-test.js"></script>
7 <p id=
"description"></p>
8 <div id=
"console"></div>
10 <input type=
"text" size=
"5" value=
"12345" maxlength=
"4" id=
"input1">
11 <input type=
"text" size=
"5" maxlength=
"4" value=
"12345" id=
"input2">
12 <input type=
"text" id=
"f" size=
"5" maxlength=
"4" value=
"123">
13 <input type=
"text" id=
"e" size=
"5" maxlength=
"4" value=
"123">
14 <input type=
"text" id=
"d" size=
"5" value=
"12345">
15 <input type=
"text" id=
"c" size=
"5" value=
"12345">
16 <input type=
"text" size=
"5" value=
"12x̲̅45" maxlength=
"4" id=
"input7">
17 <input type=
"text" size=
"5" maxlength=
"4" value=
"12x̲̅45" id=
"input8">
18 <input type=
"text" id=
"j" size=
"5" maxlength=
"4" value=
"123">
19 <input type=
"text" id=
"i" size=
"5" maxlength=
"4" value=
"123">
20 <input type=
"text" id=
"h" size=
"5" value=
"12x̲̅45">
21 <input type=
"text" id=
"g" size=
"5" value=
"12x̲̅45">
24 function domValueOf(id
) {
25 return document
.getElementById(id
).value
;
27 function visibleValueOf(id
) {
28 var el
= document
.getElementById(id
);
30 document
.execCommand('SelectAll');
31 return document
.getSelection().toString();
34 var fancyX
= "x" + String
.fromCharCode(0x305) + String
.fromCharCode(0x332);
36 debug('maxlength and value that violates it, maxlength first');
37 shouldBe('domValueOf("input1")', '"12345"');
38 shouldBe('visibleValueOf("input1")', '"12345"');
40 debug('maxlength and value that violates it, maxlength first');
41 shouldBe('domValueOf("input2")', '"12345"');
42 shouldBe('visibleValueOf("input2")', '"12345"');
44 debug('set value attribute that violates maxlength');
45 document
.getElementById("f").setAttribute('value', '12345');
46 shouldBe('domValueOf("f")', '"12345"');
47 shouldBe('visibleValueOf("input2")', '"12345"');
49 debug('set value property that violates maxlength');
50 document
.getElementById("e").value
= '12345';
51 shouldBe('domValueOf("e")', '"12345"');
52 shouldBe('visibleValueOf("e")', '"12345"');
54 debug('set maxlength attribute that is smaller than initial value');
55 document
.getElementById("d").setAttribute('maxlength', 4);
56 shouldBe('domValueOf("d")', '"12345"');
57 shouldBe('visibleValueOf("d")', '"12345"');
59 debug('set maxLength property that is smaller than initial value');
60 document
.getElementById("c").maxLength
= 4;
61 shouldBe('domValueOf("c")', '"12345"');
62 shouldBe('visibleValueOf("c")', '"12345"');
64 debug('maxlength and value that violates it, maxlength first');
65 shouldBe('domValueOf("input7")', '"12" + fancyX + "45"');
66 shouldBe('visibleValueOf("input7")', '"12" + fancyX + "45"');
68 debug('maxlength and value that violates it, value first');
69 shouldBe('domValueOf("input8")', '"12" + fancyX + "45"');
70 shouldBe('visibleValueOf("input8")', '"12" + fancyX + "45"');
72 debug('set value attribute that violates maxlength');
73 document
.getElementById("j").setAttribute('value', '12' + fancyX
+ '45');
74 shouldBe('domValueOf("j")', '"12" + fancyX + "45"');
75 shouldBe('visibleValueOf("j")', '"12" + fancyX + "45"');
77 debug('set value property that violates maxlength');
78 document
.getElementById("i").value
= '12' + fancyX
+ '45';
79 shouldBe('domValueOf("i")', '"12" + fancyX + "45"');
80 shouldBe('visibleValueOf("i")', '"12" + fancyX + "45"');
82 debug('set maxlength attribute that is smaller than initial value');
83 document
.getElementById("h").setAttribute('maxlength', 4);
84 shouldBe('domValueOf("h")', '"12" + fancyX + "45"');
85 shouldBe('visibleValueOf("h")', '"12" + fancyX + "45"');
87 debug('set maxLength property that is smaller than initial value');
88 document
.getElementById("g").maxLength
= 4;
89 shouldBe('domValueOf("g")', '"12" + fancyX + "45"');
90 shouldBe('visibleValueOf("g")', '"12" + fancyX + "45"');