| <script> |
| if (window.testRunner) { |
| testRunner.dumpEditingCallbacks(); |
| testRunner.dumpAsText(); |
| } |
| |
| var sel = window.getSelection(); |
| |
| function logResult(str) { |
| if (str != 'SUCCESS') |
| str += ' baseOffset: ' + sel.baseOffset + ' extentOffset: ' + sel.extentOffset; |
| document.getElementById('result').innerHTML = str; |
| } |
| |
| function runTest() { |
| if (!window.testRunner) { |
| log('This test must be run by DumpRenderTree!') |
| return; |
| } |
| |
| var onMacPlatform = navigator.userAgent.search(/\bMac OS X\b/) != -1; |
| |
| var area = document.getElementById('area'); |
| area.focus(); |
| |
| // Now move to the end |
| if (onMacPlatform) |
| eventSender.keyDown("rightArrow", ["metaKey"]); |
| else |
| eventSender.keyDown("end"); |
| |
| if (sel.baseOffset != 9 || sel.extentOffset != 9) { |
| logResult("Selection should be at the end."); |
| return; |
| } |
| |
| // Now move back to the beginning |
| if (onMacPlatform) |
| eventSender.keyDown("leftArrow", ["metaKey"]); |
| else |
| eventSender.keyDown("home"); |
| |
| if (sel.baseOffset != 0 || sel.extentOffset != 0) { |
| logResult("Selection should be at the beginning."); |
| return; |
| } |
| |
| // Now move to the end, selecting |
| if (onMacPlatform) |
| eventSender.keyDown("rightArrow", ["metaKey", "shiftKey"]); |
| else |
| eventSender.keyDown("end",["shiftKey"]); |
| |
| if (sel.baseOffset != 0 || sel.extentOffset != 9) { |
| logResult("Selection should contain the whole line and have forward directionality."); |
| return; |
| } |
| |
| // Deselect but position the caret at the end |
| eventSender.keyDown("rightArrow"); |
| |
| if (sel.baseOffset != 9 || sel.extentOffset != 9) { |
| logResult("Selection should be at the end."); |
| return; |
| } |
| |
| // Now move to the beginning, selecting |
| if (onMacPlatform) |
| eventSender.keyDown("leftArrow", ["metaKey", "shiftKey"]); |
| else |
| eventSender.keyDown("home",["shiftKey"]); |
| |
| if (sel.baseOffset != 9 || sel.extentOffset != 0) { |
| logResult("Selection should contain the whole line and have backward directionality."); |
| return; |
| } |
| |
| logResult('SUCCESS'); |
| } |
| </script> |
| <body onload="runTest();"> |
| <div contenteditable id="area">Some text</div> |
| <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> |
| <div id="result">FAILURE</div> |
| </body> |