layout/generic/test/test_bug438840.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial