layout/generic/test/test_bug438840.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/generic/test/test_bug438840.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,52 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Test Character Movement (including nsTextFrame::PeekOffsetCharacter)</title>
     1.8 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    1.10 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.11 +</head>
    1.12 +<body>
    1.13 +<p id="display"></p>
    1.14 +<div>content before the editor</div>
    1.15 +<div contentEditable="true" id="editor" style="width:200px;height:150px;overflow-y:auto;overflow-x:hidden;"><p>paragraph1</p>
    1.16 +<p>paragraph2</p>
    1.17 +<p>paragraph3</p>
    1.18 +<p>paragraph4</p>
    1.19 +<p>paragraph5</p>
    1.20 +<p>paragraph6</p>
    1.21 +</div>
    1.22 +<div>content after the editor</div>
    1.23 +<pre id="test">
    1.24 +<script class="testbody" type="text/javascript;version=1.7">
    1.25 +
    1.26 +function test() {
    1.27 +  var sel = window.getSelection();
    1.28 +  var editor = document.getElementById("editor");
    1.29 +
    1.30 +  var keymodifier={};
    1.31 +  //in windows/linux, pageup/pagedown will trigger movement of caret
    1.32 +  //while in Mac, pageup/pagedown will just scroll. We need to press
    1.33 +  //alt-pageup/pagedown in Mac to actually move caret
    1.34 +  if(navigator.platform.indexOf("Mac") >= 0){
    1.35 +    keymodifier.altKey=true;
    1.36 +  }
    1.37 +
    1.38 +  sel.collapse(editor.firstChild.firstChild, 1);
    1.39 +  synthesizeKey("VK_PAGE_UP", keymodifier);
    1.40 +  is(sel.anchorNode, editor.firstChild.firstChild, 'after pageup caret should still be in the first paragraph');
    1.41 +
    1.42 +  synthesizeKey("VK_PAGE_DOWN", keymodifier);
    1.43 +  is(sel.anchorNode.parentNode.parentNode, editor, 'pagedown should not move caret outside the editor');
    1.44 +
    1.45 +  SimpleTest.finish();
    1.46 +}
    1.47 +
    1.48 +SimpleTest.waitForExplicitFinish();
    1.49 +SimpleTest.waitForFocus(test);
    1.50 +
    1.51 +
    1.52 +</script>
    1.53 +</pre>
    1.54 +</body>
    1.55 +</html>

mercurial