OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script> | 3 <script> |
4 function test () { | 4 function test () { |
5 var testField = document.getElementById('t1'); | 5 var testField = document.getElementById('t1'); |
6 var results = document.getElementById('result'); | 6 var results = document.getElementById('result'); |
7 | 7 |
8 testSelectionRange(1, 0, 0, 0, 0, testField, results); | 8 testSelectionRange(1, 0, 0, 0, 0, testField, results); |
9 testSelectionEnd(2, 17, 0, 17, testField, results); | 9 testSelectionEnd(2, 17, 0, 17, testField, results); |
10 testSelectionStart(3, 1, 1, 17, testField, results); | 10 testSelectionStart(3, 1, 1, 17, testField, results); |
11 testSelectionRange(4, 10, 3, 3, 3, testField, results); | 11 testSelectionRange(4, 10, 3, 3, 3, testField, results); |
12 testSelectionEnd(5, 2, 2, 2, testField, results); | 12 testSelectionEnd(5, 2, 2, 2, testField, results); |
13 testSelectionRange(6, 5, 4, 4, 4, testField, results); | 13 testSelectionRange(6, 5, 4, 4, 4, testField, results); |
14 testSelectionRange(7, -5, -4, 0, 0, testField, results); | 14 testSelectionRange(7, -5, -4, 20, 20, testField, results); |
15 testSelectionRange(8, -5, 80, 0, 20, testField, results); | 15 testSelectionRange(8, -5, 80, 20, 20, testField, results); |
16 testSelectionRange(9, 3, 12, 3, 12, testField, results); | 16 testSelectionRange(9, 3, 12, 3, 12, testField, results); |
17 | 17 |
18 } | 18 } |
19 | 19 |
20 function testSelectionRange (testNumber, start, end, expectedStart, expectedEnd,
tf, res) | 20 function testSelectionRange (testNumber, start, end, expectedStart, expectedEnd,
tf, res) |
21 { | 21 { |
22 tf.focus(); | 22 tf.focus(); |
23 tf.setSelectionRange(start, end); | 23 tf.setSelectionRange(start, end); |
24 res.innerHTML = res.innerHTML + "<br>Test " + testNumber + ": setSelectionRa
nge(" + start + ", " + end + ")"; | 24 res.innerHTML = res.innerHTML + "<br>Test " + testNumber + ": setSelectionRa
nge(" + start + ", " + end + ")"; |
25 if (tf.selectionStart == expectedStart && tf.selectionEnd == expectedEnd) | 25 if (tf.selectionStart == expectedStart && tf.selectionEnd == expectedEnd) |
(...skipping 25 matching lines...) Expand all Loading... |
51 </script> | 51 </script> |
52 </head> | 52 </head> |
53 <body onload="test()"> | 53 <body onload="test()"> |
54 This tests the selection methods on the new text field. | 54 This tests the selection methods on the new text field. |
55 <p> | 55 <p> |
56 <input type="text" id="t1" style="-khtml-appearance:textfield" value="123456789
ABCDEFGHIJ"></input> | 56 <input type="text" id="t1" style="-khtml-appearance:textfield" value="123456789
ABCDEFGHIJ"></input> |
57 <div id="result"></div> | 57 <div id="result"></div> |
58 </p> | 58 </p> |
59 </body> | 59 </body> |
60 </html> | 60 </html> |
OLD | NEW |