OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <script> |
| 3 |
| 4 function logResult(str) { |
| 5 if (str != 'SUCCESS') |
| 6 str += ' baseOffset: ' + sel.baseOffset + ' extentOffset: ' + sel.extent
Offset; |
| 7 document.getElementById('result').innerHTML = str; |
| 8 } |
| 9 |
| 10 function runTest() { |
| 11 if (!window.testRunner) { |
| 12 log('This test must be run by DumpRenderTree!') |
| 13 return; |
| 14 } |
| 15 testRunner.overridePreference("WebKitEnableCaretBrowsing", false); |
| 16 testRunner.dumpAsText(); |
| 17 |
| 18 var onMacPlatform = navigator.userAgent.search(/\bMac OS X\b/) != -1; |
| 19 |
| 20 var target = document.getElementById('target'); |
| 21 target.focus(); |
| 22 |
| 23 window.getSelection().setPosition(target.childNodes.item(0), 3); |
| 24 // Now move to the end, selecting |
| 25 if (onMacPlatform) |
| 26 eventSender.keyDown("rightArrow", ["metaKey", "shiftKey"]); |
| 27 else |
| 28 eventSender.keyDown("end",["shiftKey"]); |
| 29 |
| 30 if (!((getSelection().baseOffset == 3) && (getSelection().extentOffset == 9)
)) { |
| 31 logResult("Selection should contain the line starting from baseOffset ti
ll the end of the line with forward directionality."); |
| 32 return; |
| 33 } |
| 34 |
| 35 window.getSelection().setPosition(target.childNodes.item(0), 3); |
| 36 |
| 37 // Now move to the beginning, selecting |
| 38 if (onMacPlatform) |
| 39 eventSender.keyDown("leftArrow", ["metaKey", "shiftKey"]); |
| 40 else |
| 41 eventSender.keyDown("home",["shiftKey"]); |
| 42 |
| 43 if (!((getSelection().baseOffset == 3) && (getSelection().extentOffset == 0)
)) { |
| 44 logResult("Selection should contain the line starting from baseOffset ti
ll the beginning of the line with backward directionality."); |
| 45 return; |
| 46 } |
| 47 |
| 48 logResult('SUCCESS'); |
| 49 } |
| 50 </script> |
| 51 <body onload="runTest();"> |
| 52 <div contenteditable="false" id="target">Some text</div> |
| 53 <p>This tests selection using Command+Left/Right arrows in Mac and Shift+Hom
e/End in other platform for readonly texts. If this test is successful, the text
"SUCCESS" will be shown below.</p> |
| 54 <div id="result">FAILURE</div> |
| 55 </body> |
| 56 </html> |
OLD | NEW |