blob: 7d83fb1fa1e58b5e7415e2f3ae1f294dc2deec1d [file] [log] [blame]
<html>
<head>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
internals.settings.setSmartInsertDeleteEnabled(false);
internals.settings.setSelectTrailingWhitespaceEnabled(true);
}
function getPositionOfNode(id)
{
var n = document.getElementById(id);
var pos = {x: 0, y: 0};
while (n) {
pos.x += n.offsetLeft + n.clientLeft;
pos.y += n.offsetTop + n.clientTop;
n = n.offsetParent;
}
return pos;
}
function doubleClickNode(id)
{
var pos = getPositionOfNode(id);
eventSender.mouseMoveTo(pos.x + 2, pos.y + 2);
eventSender.mouseDown();
eventSender.leapForward(1);
eventSender.mouseUp();
eventSender.leapForward(100);
eventSender.mouseDown();
eventSender.leapForward(1);
eventSender.mouseUp();
}
function doTest(testId, expectedText)
{
// Simulate a double click.
doubleClickNode(testId);
// Get the text of the current selection.
var sel = window.getSelection();
var actualText = sel.getRangeAt(0).toString();
if (expectedText == actualText) {
log("Passed " + testId);
} else {
log("Failed " + testId);
log(" Expected: " + expectedText);
log(" Actual: " + actualText);
}
}
function runTests()
{
if (window.testRunner) {
doTest("test1", "Doubleclickme \u00a0\u00a0\u00a0 ");
doTest("test2", "Doubleclickme");
doTest("test3", "Doubleclickme \u00a0\u00a0 ");
doTest("test4", "Doubleclickme");
doTest("test5", "Doubleclickme \u00a0\u00a0");
doTest("test6", "Doubleclickme \u00a0\t\t\t\u00a0");
}
}
function log(msg)
{
var l = document.getElementById('log');
l.appendChild(document.createTextNode(msg));
l.appendChild(document.createElement('br'));
}
</script>
</head>
<body onload="runTests()">
<p>
This tests that double-clicking a word on the Windows platform selects the whitespace after the word.
</p>
<div>
<span id=test1>Doubleclickme &nbsp;&nbsp;&nbsp; |END|</span>
</div>
<div>
<span id=test2>Doubleclickme|END|</span>
</div>
<div>
<span id=test3>Doubleclickme</span> &nbsp;&nbsp;
|END|</span>
</div>
<div>
<div>
<span id="test4">Doubleclickme</span>
</div>
&nbsp;&nbsp;&nbsp;|(Should not have been extended into this line)|
</div>
<div>
<span id="test5">Doubleclickme </span> &nbsp;&nbsp;<img src="does-not-exist.png" />&nbsp; &nbsp;
</div>
<pre>
<span id="test6">Doubleclickme </span> &nbsp; &nbsp;|END|
</pre>
<br/>
<pre id=log>
</pre>
</body>
</html>