gecko/content/base/test/test_bug654352.html
Brad Lassey 7b68e9930e bug 654352 - follow up to make test for document.caretPositionFromPoint API more reliable r=me
--HG--
extra : rebase_source : f9c86be2647c942ad807cc9d31a10650ce68b58f
2011-08-18 19:05:49 -04:00

51 lines
1.8 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=654352
-->
<head>
<title>Test for Bug 654352</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=654352">Mozilla Bug 654352</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 654352 **/
SimpleTest.waitForExplicitFinish();
function afterLoad() {
var testpre = document.getElementById("testpre");
var rect1 = testpre.getBoundingClientRect();
dump(rect1 + "\n");
var caret1 = document.caretPositionFromPoint(rect1.right - 5, rect1.top + 10);
ok(caret1.offsetNode == testpre.firstChild, "node in CaretPosition not correct (" + caret1.offsetNode + " == " + testpre.firstChild + ")")
ok(caret1.offset == 9, "offset in CaretPosition not correct (" + caret1.offset + "== 9)")
var testinput = document.getElementById("testinput");
var rect2 = testinput.getBoundingClientRect();
dump(rect2.top +", " + rect2.left + "\n");
var caret2 = document.caretPositionFromPoint( rect2.right - 5, rect2.top + 10);
ok(caret2.offsetNode == testinput, "node in CaretPosition not correct (" + caret2.offsetNode + " == " + testinput + ")")
ok(caret2.offset == 9, "offset in CaretPosition not correct (" + caret2.offset + "== 9)")
SimpleTest.finish();
};
addLoadEvent(afterLoad);
</script>
</pre>
<span id="testdiv">
<pre id="testpre">test text</pre>
</span>
<br>
<br>
</div>
<input id="testinput" type="text" value="test text"></input>
</div>
</body>
</html>