blob: cd102d7677b6c781788496a984cb907620bb018d [file] [log] [blame]
<head>
<style>
span:before {
content: "<before> ";
}
span:after {
content: " <after>";
}
</style>
<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();
var block = document.getElementById("block");
var x = block.offsetLeft + 5;
var y = block.offsetTop + 5;
if (window.eventSender) {
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
eventSender.mouseUp();
}
if (checkSelection(1, "(text in span, 0), (text in span, 0)"))
return;
x = block.offsetLeft + 200;
if (window.eventSender) {
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
eventSender.mouseUp();
}
if (checkSelection(2, "(text in span, 24), (text in span, 24)"))
return;
document.getElementById("result").innerHTML = "SUCCESS";
}
</script>
</head>
<body onload="runTest()">
<p>This tests clicking in anonymous content to see if a selection is successfully created.</p>
<p id="block" contentEditable style="border: 1px solid blue"><span id="span">This is the selectable text.</span></div>
<p id="result">TEST DID NOT RUN</div>
</body>