blob: 7b2e2673a2381f73345093884fd0b1f1b67de314 [file] [log] [blame]
<html>
<head>
<script>
function nodeAsString(node)
{
if (node && node.nodeType == Node.TEXT_NODE)
return "text in " + nodeAsString(node.parentNode);
if (node && node.nodeType == Node.ELEMENT_NODE) {
var id;
if (id = node.getAttribute("id"))
return id;
}
return node;
}
function selectionAsString()
{
return "(" + nodeAsString(getSelection().anchorNode)
+ ", " + getSelection().anchorOffset
+ "), (" + nodeAsString(getSelection().focusNode)
+ ", " + getSelection().focusOffset + ")";
}
function checkSelection(step, expected)
{
if (selectionAsString() !== expected) {
document.getElementById("result").innerHTML = "FAIL: After step " + step + " selection was " + selectionAsString();
return true;
}
return false;
}
function runTest()
{
if (window.layoutTestController)
layoutTestController.dumpAsText();
getSelection().setPosition(document.getElementById("first").firstChild, 4);
if (checkSelection(1, "(text in first, 4), (text in first, 4)"))
return;
getSelection().modify("extend", "backward", "line");
if (checkSelection(2, "(text in first, 4), (text in first, 0)"))
return;
getSelection().setPosition(document.getElementById("last").firstChild, 4);
if (checkSelection(3, "(text in last, 4), (text in last, 4)"))
return;
getSelection().modify("extend", "forward", "line");
if (checkSelection(4, "(text in last, 4), (text in last, 61)"))
return;
getSelection().setPosition(document.getElementById("first").firstChild, 4);
if (checkSelection(5, "(text in first, 4), (text in first, 4)"))
return;
getSelection().modify("extend", "backward", "paragraph");
if (checkSelection(6, "(text in first, 4), (text in first, 0)"))
return;
getSelection().setPosition(document.getElementById("last").firstChild, 4);
if (checkSelection(7, "(text in last, 4), (text in last, 4)"))
return;
getSelection().modify("extend", "forward", "paragraph");
if (checkSelection(8, "(text in last, 4), (text in last, 61)"))
return;
document.getElementById("result").innerHTML = "SUCCESS";
}
</script>
</head>
<body onload="runTest()"><p id="first">This is the first paragraph, used for the moving-backward test.</p>
<p>This tests for a problem with selections at document edges.</p>
<p id="result">TEST HAS NOT YET RUN.</p>
<p id="last">This is the last paragraph, used for the moving-forward test.</p>
</body>
</html>