Patch by Kevin Ballard <kevin@sb.org>
[WebKit-https.git] / LayoutTests / fast / forms / cursor-position.html
1 <html>
2     <head>
3         <script type="text/javascript">
4             function print(message)
5             {
6                 var paragraph = document.createElement("li");
7                 paragraph.appendChild(document.createTextNode(message));
8                 document.getElementById("console").appendChild(paragraph);
9             }
10             function test()
11             {
12                 if (window.layoutTestController) {
13                     layoutTestController.dumpAsText();
14                 }
15                 var elt = document.getElementById("text");
16                 txt = "this is\ra test\rof cursor";
17                 txt2 = "this is\na test\nof cursor!";
18                 
19                 // test getCursorPosition...
20                 elt.value = txt;
21                 elt.setSelectionRange(10, 14);
22                 elt.focus();
23                 elt.value = txt2;
24                 elt.focus();
25                 print(elt.selectionStart.toString() + ", " + elt.selectionEnd.toString());
26                 
27                 // test setCursorPosition...
28                 elt.value = txt2;
29                 elt.setSelectionRange(10, 14);
30                 elt.focus();
31                 elt.value = txt;
32                 elt.focus();
33                 print(elt.selectionStart.toString() + ", " + elt.selectionEnd.toString());
34             }
35         </script>
36     </head>
37     <body onload="test();">
38         <p>This test sets a non-standard line endings, sets selection, then sets a standard line ending string, and checks selection.</p>
39         <p>If this test succeeded, you should see 2 lines saying "10, 10" below.</p>
40         <hr />
41         <form>
42             <textarea id="text"></textarea>
43         </form>
44         <hr />
45         <p><ol id="console"></ol></p>
46     </body>
47 </html>