| OLD | NEW |
| 1 <script> | 1 <script> |
| 2 if (window.testRunner) { | 2 if (window.testRunner) { |
| 3 testRunner.dumpEditingCallbacks(); | 3 testRunner.dumpEditingCallbacks(); |
| 4 testRunner.dumpAsText(); | 4 testRunner.dumpAsText(); |
| 5 } | 5 } |
| 6 | 6 |
| 7 var sel = window.getSelection(); | 7 var sel = window.getSelection(); |
| 8 | 8 |
| 9 function logResult(str) { | 9 function logResult(str) { |
| 10 if (str != 'SUCCESS') | 10 if (str != 'SUCCESS') |
| 11 str += ' baseOffset: ' + sel.baseOffset + ' extentOffset: ' + sel.extent
Offset; | 11 str += ' baseOffset: ' + sel.baseOffset + ' extentOffset: ' + sel.extent
Offset; |
| 12 document.getElementById('result').innerHTML = str; | 12 document.getElementById('result').innerHTML = str; |
| 13 } | 13 } |
| 14 | 14 |
| 15 function runTest() { | 15 function runTest() { |
| 16 if (!window.testRunner) { | 16 if (!window.testRunner) { |
| 17 log('This test must be run by DumpRenderTree!') | 17 log('This test must be run by DumpRenderTree!') |
| 18 return; | 18 return; |
| 19 } | 19 } |
| 20 | 20 |
| 21 var onMacPlatform = navigator.userAgent.search(/\bMac OS X\b/) != -1; | 21 var onMacPlatform = navigator.userAgent.search(/\bMac OS X\b/) != -1; |
| 22 | 22 |
| 23 var area = document.getElementById('area'); | 23 var area = document.getElementById('area'); |
| 24 area.focus(); | 24 area.focus(); |
| 25 | 25 |
| 26 // Now move to the end | 26 // Now move to the end |
| 27 if (onMacPlatform) | 27 if (onMacPlatform) |
| 28 eventSender.keyDown("rightArrow", ["metaKey"]); | 28 eventSender.keyDown("ArrowRight", ["metaKey"]); |
| 29 else | 29 else |
| 30 eventSender.keyDown("end"); | 30 eventSender.keyDown("End"); |
| 31 | 31 |
| 32 if (sel.baseOffset != 9 || sel.extentOffset != 9) { | 32 if (sel.baseOffset != 9 || sel.extentOffset != 9) { |
| 33 logResult("Selection should be at the end."); | 33 logResult("Selection should be at the end."); |
| 34 return; | 34 return; |
| 35 } | 35 } |
| 36 | 36 |
| 37 // Now move back to the beginning | 37 // Now move back to the beginning |
| 38 if (onMacPlatform) | 38 if (onMacPlatform) |
| 39 eventSender.keyDown("leftArrow", ["metaKey"]); | 39 eventSender.keyDown("ArrowLeft", ["metaKey"]); |
| 40 else | 40 else |
| 41 eventSender.keyDown("home"); | 41 eventSender.keyDown("Home"); |
| 42 | 42 |
| 43 if (sel.baseOffset != 0 || sel.extentOffset != 0) { | 43 if (sel.baseOffset != 0 || sel.extentOffset != 0) { |
| 44 logResult("Selection should be at the beginning."); | 44 logResult("Selection should be at the beginning."); |
| 45 return; | 45 return; |
| 46 } | 46 } |
| 47 | 47 |
| 48 // Now move to the end, selecting | 48 // Now move to the end, selecting |
| 49 if (onMacPlatform) | 49 if (onMacPlatform) |
| 50 eventSender.keyDown("rightArrow", ["metaKey", "shiftKey"]); | 50 eventSender.keyDown("ArrowRight", ["metaKey", "shiftKey"]); |
| 51 else | 51 else |
| 52 eventSender.keyDown("end",["shiftKey"]); | 52 eventSender.keyDown("End",["shiftKey"]); |
| 53 | 53 |
| 54 if (sel.baseOffset != 0 || sel.extentOffset != 9) { | 54 if (sel.baseOffset != 0 || sel.extentOffset != 9) { |
| 55 logResult("Selection should contain the whole line and have forward dire
ctionality."); | 55 logResult("Selection should contain the whole line and have forward dire
ctionality."); |
| 56 return; | 56 return; |
| 57 } | 57 } |
| 58 | 58 |
| 59 // Deselect but position the caret at the end | 59 // Deselect but position the caret at the end |
| 60 eventSender.keyDown("rightArrow"); | 60 eventSender.keyDown("ArrowRight"); |
| 61 | 61 |
| 62 if (sel.baseOffset != 9 || sel.extentOffset != 9) { | 62 if (sel.baseOffset != 9 || sel.extentOffset != 9) { |
| 63 logResult("Selection should be at the end."); | 63 logResult("Selection should be at the end."); |
| 64 return; | 64 return; |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Now move to the beginning, selecting | 67 // Now move to the beginning, selecting |
| 68 if (onMacPlatform) | 68 if (onMacPlatform) |
| 69 eventSender.keyDown("leftArrow", ["metaKey", "shiftKey"]); | 69 eventSender.keyDown("ArrowLeft", ["metaKey", "shiftKey"]); |
| 70 else | 70 else |
| 71 eventSender.keyDown("home",["shiftKey"]); | 71 eventSender.keyDown("Home",["shiftKey"]); |
| 72 | 72 |
| 73 if (sel.baseOffset != 9 || sel.extentOffset != 0) { | 73 if (sel.baseOffset != 9 || sel.extentOffset != 0) { |
| 74 logResult("Selection should contain the whole line and have backward dir
ectionality."); | 74 logResult("Selection should contain the whole line and have backward dir
ectionality."); |
| 75 return; | 75 return; |
| 76 } | 76 } |
| 77 | 77 |
| 78 logResult('SUCCESS'); | 78 logResult('SUCCESS'); |
| 79 } | 79 } |
| 80 </script> | 80 </script> |
| 81 <body onload="runTest();"> | 81 <body onload="runTest();"> |
| 82 <div contenteditable id="area">Some text</div> | 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 s
hown below.</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 s
hown below.</div> |
| 84 <div id="result">FAILURE</div> | 84 <div id="result">FAILURE</div> |
| 85 </body> | 85 </body> |
| OLD | NEW |