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, 0, 0, testField, results); |
15 testSelectionRange(8, -5, 80, 0, 20, testField, results); | 15 testSelectionRange(8, -5, 80, 0, 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.setSelectionRange(start, end); | 23 tf.setSelectionRange(start, end); |
23 res.innerHTML = res.innerHTML + "<br>Test " + testNumber + ": setSelectionRa
nge(" + start + ", " + end + ")"; | 24 res.innerHTML = res.innerHTML + "<br>Test " + testNumber + ": setSelectionRa
nge(" + start + ", " + end + ")"; |
24 if (tf.selectionStart == expectedStart && tf.selectionEnd == expectedEnd) | 25 if (tf.selectionStart == expectedStart && tf.selectionEnd == expectedEnd) |
25 res.innerHTML = res.innerHTML + "<br>Passed.<br>"; | 26 res.innerHTML = res.innerHTML + "<br>Passed.<br>"; |
26 else | 27 else |
27 res.innerHTML = res.innerHTML + "<br>Failed.<br>"; | 28 res.innerHTML = res.innerHTML + "<br>Failed.<br>"; |
28 } | 29 } |
29 | 30 |
30 function testSelectionStart (testNumber, start, expectedStart, expectedEnd, tf,
res) | 31 function testSelectionStart (testNumber, start, expectedStart, expectedEnd, tf,
res) |
31 { | 32 { |
(...skipping 18 matching lines...) Expand all Loading... |
50 </script> | 51 </script> |
51 </head> | 52 </head> |
52 <body onload="test()"> | 53 <body onload="test()"> |
53 This tests the selection methods on the new text field. | 54 This tests the selection methods on the new text field. |
54 <p> | 55 <p> |
55 <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> |
56 <div id="result"></div> | 57 <div id="result"></div> |
57 </p> | 58 </p> |
58 </body> | 59 </body> |
59 </html> | 60 </html> |
OLD | NEW |