41 lines
1.1 KiB
HTML
41 lines
1.1 KiB
HTML
<!DOCTYPE html>
|
|
<div id="target" style="
|
|
outline: dashed lightblue;
|
|
width: 150px;
|
|
padding: 25px;
|
|
font: 20px ahem;
|
|
-webkit-writing-mode: horizontal-bt;
|
|
">Lorem ipsum dolor sit amet</div>
|
|
<pre id="log"></pre>
|
|
<script>
|
|
if (window.testRunner && window.internals) {
|
|
testRunner.dumpAsText();
|
|
internals.settings.setEditingBehavior("mac");
|
|
}
|
|
|
|
function log(message)
|
|
{
|
|
document.getElementById("log").appendChild(document.createTextNode(message + "\n"));
|
|
}
|
|
|
|
function test(x, y, expectedOffset)
|
|
{
|
|
var actualOffset = document.caretRangeFromPoint(8 + x, 8 + y).startOffset;
|
|
if (actualOffset === expectedOffset)
|
|
log("PASS: offset at (" + x + "," + y + ") was " + actualOffset + ".");
|
|
else
|
|
log("FAIL: offset at (" + x + "," + y + ") was " + actualOffset + ". Expected " + expectedOffset + ".");
|
|
}
|
|
|
|
test(100, 105, 4);
|
|
test(160, 105, 5);
|
|
test(100, 104, 10);
|
|
test(160, 104, 11);
|
|
test(60, 26, 24);
|
|
test(160, 26, 26);
|
|
test(60, 25, 24);
|
|
test(160, 25, 26);
|
|
test(60, 24, 26);
|
|
test(160, 24, 26);
|
|
</script>
|