test_bug438840.html (1589B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Test Character Movement (including nsTextFrame::PeekOffsetCharacter)</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <script src="/tests/SimpleTest/EventUtils.js"></script> 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 8 </head> 9 <body> 10 <p id="display"></p> 11 <div>content before the editor</div> 12 <div contentEditable="true" id="editor" style="width:200px;height:150px;overflow-y:auto;overflow-x:hidden;"><p>paragraph1</p> 13 <p>paragraph2</p> 14 <p>paragraph3</p> 15 <p>paragraph4</p> 16 <p>paragraph5</p> 17 <p>paragraph6</p> 18 </div> 19 <div>content after the editor</div> 20 <pre id="test"> 21 <script class="testbody" type="text/javascript"> 22 23 function test() { 24 var sel = window.getSelection(); 25 var editor = document.getElementById("editor"); 26 27 var keymodifier={}; 28 //in windows/linux, pageup/pagedown will trigger movement of caret 29 //while in Mac, pageup/pagedown will just scroll. We need to press 30 //alt-pageup/pagedown in Mac to actually move caret 31 if(navigator.platform.includes("Mac")){ 32 keymodifier.altKey=true; 33 } 34 35 sel.collapse(editor.firstChild.firstChild, 1); 36 synthesizeKey("VK_PAGE_UP", keymodifier); 37 is(sel.anchorNode, editor.firstChild.firstChild, 'after pageup caret should still be in the first paragraph'); 38 39 synthesizeKey("VK_PAGE_DOWN", keymodifier); 40 is(sel.anchorNode.parentNode.parentNode, editor, 'pagedown should not move caret outside the editor'); 41 42 SimpleTest.finish(); 43 } 44 45 SimpleTest.waitForExplicitFinish(); 46 SimpleTest.waitForFocus(test); 47 48 49 </script> 50 </pre> 51 </body> 52 </html>