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