diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /layout/generic/test/test_movement_by_characters.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'layout/generic/test/test_movement_by_characters.html')
-rw-r--r-- | layout/generic/test/test_movement_by_characters.html | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/layout/generic/test/test_movement_by_characters.html b/layout/generic/test/test_movement_by_characters.html new file mode 100644 index 000000000..ffd423335 --- /dev/null +++ b/layout/generic/test/test_movement_by_characters.html @@ -0,0 +1,97 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test Character Movement (including nsTextFrame::PeekOffsetCharacter)</title> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<p id="display"></p> +<div id="content" style="display: block"> +<div contentEditable id="editor"></div> +</div> +<pre id="test"> +<script class="testbody" type="text/javascript;version=1.7"> + +SimpleTest.waitForExplicitFinish(); + +if (navigator.userAgent.indexOf("Windows NT 6.2") >= 0) { + todo(false, "Too many intermittent failures on Windows 8 (bug 886781)"); + SimpleTest.finish(); +} else { + setTimeout(focusing, 0); +} + +function focusing() { + document.getElementById("editor").focus(); + // This seems to be necessary because the selection is not set up properly otherwise + setTimeout(test, 0); +} + +function test() { + var sel = window.getSelection(); + var editor = document.getElementById("editor"); + + function testRight(node, offset) { + synthesizeKey("VK_RIGHT", {}); + is(sel.anchorNode, node, "Right movement broken in " + editor.innerHTML); + is(sel.anchorOffset, offset, "Right movement broken in " + editor.innerHTML); + } + + function testLeft(node, offset) { + synthesizeKey("VK_LEFT", {}); + is(sel.anchorNode, node, "Left movement broken in " + editor.innerHTML); + is(sel.anchorOffset, offset, "Left movement broken in " + editor.innerHTML); + } + + editor.innerHTML = "H K"; + sel.collapse(editor.firstChild, 0); + testRight(editor.firstChild, 1); + testRight(editor.firstChild, 2); + testRight(editor.firstChild, 3); + testLeft(editor.firstChild, 2); + testLeft(editor.firstChild, 1); + testLeft(editor.firstChild, 0); + + editor.innerHTML = "<b>H</b> K"; + sel.collapse(editor.firstChild.firstChild, 0); + testRight(editor.firstChild.firstChild, 1); + testRight(editor.firstChild.nextSibling, 1); + testRight(editor.firstChild.nextSibling, 2); + testLeft(editor.firstChild.nextSibling, 1); + testLeft(editor.firstChild.nextSibling, 0); + testLeft(editor.firstChild.firstChild, 0); + + editor.innerHTML = "H <br>K"; + sel.collapse(editor.firstChild, 0); + testRight(editor.firstChild, 1); + testRight(editor.firstChild, 2); + testRight(editor.firstChild.nextSibling.nextSibling, 0); + testRight(editor.firstChild.nextSibling.nextSibling, 1); + testLeft(editor.firstChild.nextSibling.nextSibling, 0); + testLeft(editor.firstChild, 2); + testLeft(editor.firstChild, 1); + testLeft(editor.firstChild, 0); + + editor.innerHTML = "<pre>aa\nbb</pre>"; + sel.collapse(editor.firstChild.firstChild, 0); + testRight(editor.firstChild.firstChild, 1); + // at the end of the first line, before the \n + testRight(editor.firstChild.firstChild, 2); + testRight(editor.firstChild.firstChild, 3); + testRight(editor.firstChild.firstChild, 4); + testLeft(editor.firstChild.firstChild, 3); + // at the end of the first line, before the \n + testLeft(editor.firstChild.firstChild, 2); + testLeft(editor.firstChild.firstChild, 1); + testLeft(editor.firstChild.firstChild, 0); + + SimpleTest.finish(); +} + + +</script> +</pre> +</body> +</html> |