2 if (window
.testRunner
) {
3 testRunner
.dumpEditingCallbacks();
4 testRunner
.dumpAsText();
7 var sel
= window
.getSelection();
9 function logResult(str
) {
11 str
+= ' baseOffset: ' + sel
.baseOffset
+ ' extentOffset: ' + sel
.extentOffset
;
12 document
.getElementById('result').innerHTML
= str
;
16 if (!window
.testRunner
) {
17 log('This test must be run by DumpRenderTree!')
21 var onMacPlatform
= navigator
.userAgent
.search(/\bMac OS X\b/) != -1;
23 var area
= document
.getElementById('area');
26 // Now move to the end
28 eventSender
.keyDown("rightArrow", ["metaKey"]);
30 eventSender
.keyDown("end");
32 if (sel
.baseOffset
!= 9 || sel
.extentOffset
!= 9) {
33 logResult("Selection should be at the end.");
37 // Now move back to the beginning
39 eventSender
.keyDown("leftArrow", ["metaKey"]);
41 eventSender
.keyDown("home");
43 if (sel
.baseOffset
!= 0 || sel
.extentOffset
!= 0) {
44 logResult("Selection should be at the beginning.");
48 // Now move to the end, selecting
50 eventSender
.keyDown("rightArrow", ["metaKey", "shiftKey"]);
52 eventSender
.keyDown("end",["shiftKey"]);
54 if (sel
.baseOffset
!= 0 || sel
.extentOffset
!= 9) {
55 logResult("Selection should contain the whole line and have forward directionality.");
59 // Deselect but position the caret at the end
60 eventSender
.keyDown("rightArrow");
62 if (sel
.baseOffset
!= 9 || sel
.extentOffset
!= 9) {
63 logResult("Selection should be at the end.");
67 // Now move to the beginning, selecting
69 eventSender
.keyDown("leftArrow", ["metaKey", "shiftKey"]);
71 eventSender
.keyDown("home",["shiftKey"]);
73 if (sel
.baseOffset
!= 9 || sel
.extentOffset
!= 0) {
74 logResult("Selection should contain the whole line and have backward directionality.");
81 <body onload=
"runTest();">
82 <div contenteditable
id=
"area">Some text
</div>
83 <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>
84 <div id=
"result">FAILURE
</div>