aa6c6cf8ec51b84c08f9bec2d816f7d9a64949c0
[WebKit-https.git] / LayoutTests / editing / selection / move-begin-end.html
1 <html>
2     <head>
3         <script>
4             function runTest() {
5                 if (window.layoutTestController)
6                     layoutTestController.dumpAsText();
7                 else {
8                     alert('This test must be run by DumpRenderTree!') 
9                     return;
10                 }
11                 
12                 var area = document.getElementById('area');
13                 area.focus();
14                 
15                 var sel = window.getSelection();
16                 // Position the caret at the beginning of the string.
17                 eventSender.keyDown(String.fromCharCode(0xf702));
18
19                 // Now move to the end
20                 eventSender.keyDown(String.fromCharCode(0xf703), ["metaKey"]);
21
22                 if (sel.baseOffset != 9 || sel.extentOffset != 9)
23                     return;
24                 
25                 // Now move back to the beginning
26                 eventSender.keyDown(String.fromCharCode(0xf702), ["metaKey"]);
27
28                 if (sel.baseOffset != 0 || sel.extentOffset != 0)
29                     return;
30
31                 // Now move to the end, selecting
32                 eventSender.keyDown(String.fromCharCode(0xf703), ["metaKey", "shiftKey"]);
33
34                 if (sel.baseOffset != 0 || sel.extentOffset != 9)
35                     return;
36
37                 // Deselect but position the caret at the end                
38                 eventSender.keyDown(String.fromCharCode(0xf703));
39                 
40                 if (sel.baseOffset != 9 || sel.extentOffset != 9)
41                     return;
42                 
43                 // Now move to the beginning, selecting
44                 eventSender.keyDown(String.fromCharCode(0xf702), ["metaKey", "shiftKey"]);
45                 
46                 if (sel.baseOffset != 9 || sel.extentOffset != 0)
47                     return;
48                 
49                 document.getElementById('result').innerHTML = 'SUCCESS'
50             }
51         </script>
52     </head>
53     <body onload="runTest();">
54         <textarea id="area">Some text</textarea>
55         <div>This tests that moving the caret and selecting using Command+Left/Right arrows work correctly. If this text is successful, the text "SUCCESS" will be shown below.</div>
56         <div id="result">FAILURE</div>
57     </body>
58 </html>