|
Line 0
a/LayoutTests/editing/selection/doubleclick-beside-cr-span.html_sec1
|
|
|
1 |
<html> |
| 2 |
<head> |
| 3 |
<script> |
| 4 |
if (window.layoutTestController) { |
| 5 |
layoutTestController.dumpAsText(); |
| 6 |
layoutTestController.setSmartInsertDeleteEnabled(false); |
| 7 |
layoutTestController.setSelectTrailingWhitespaceEnabled(true); |
| 8 |
} |
| 9 |
|
| 10 |
function getPositionOfNode(id) |
| 11 |
{ |
| 12 |
var n = document.getElementById(id); |
| 13 |
var pos = {x: 0, y: 0}; |
| 14 |
|
| 15 |
while (n) { |
| 16 |
pos.x += n.offsetLeft + n.clientLeft; |
| 17 |
pos.y += n.offsetTop + n.clientTop; |
| 18 |
n = n.offsetParent; |
| 19 |
} |
| 20 |
return pos; |
| 21 |
} |
| 22 |
|
| 23 |
function doubleClickNode(id) |
| 24 |
{ |
| 25 |
var pos = getPositionOfNode(id); |
| 26 |
eventSender.mouseMoveTo(pos.x + 2, pos.y + 2); |
| 27 |
eventSender.mouseDown(); |
| 28 |
eventSender.leapForward(1); |
| 29 |
eventSender.mouseUp(); |
| 30 |
eventSender.leapForward(100); |
| 31 |
eventSender.mouseDown(); |
| 32 |
eventSender.leapForward(1); |
| 33 |
eventSender.mouseUp(); |
| 34 |
} |
| 35 |
|
| 36 |
function doTest(testId, expectedText) |
| 37 |
{ |
| 38 |
// Simulate a double click. |
| 39 |
doubleClickNode(testId); |
| 40 |
|
| 41 |
// Get the text of the current selection. |
| 42 |
var sel = window.getSelection(); |
| 43 |
var actualText = sel.getRangeAt(0).toString(); |
| 44 |
|
| 45 |
if (expectedText == actualText) { |
| 46 |
log("Passed " + testId); |
| 47 |
} else { |
| 48 |
log("Failed " + testId); |
| 49 |
log(" Expected: " + expectedText); |
| 50 |
log(" Actual: " + actualText); |
| 51 |
} |
| 52 |
|
| 53 |
} |
| 54 |
|
| 55 |
function log(msg) |
| 56 |
{ |
| 57 |
var l = document.getElementById('log'); |
| 58 |
l.appendChild(document.createTextNode(msg)); |
| 59 |
l.appendChild(document.createElement('br')); |
| 60 |
} |
| 61 |
|
| 62 |
function runTests() |
| 63 |
{ |
| 64 |
if (window.layoutTestController) { |
| 65 |
doTest("totest1", "select1"); |
| 66 |
// trailing whitespaces are ugly, but these are preexisting |
| 67 |
// behaviour - although could be filed as a bug. |
| 68 |
doTest("totest2", "select2 "); |
| 69 |
doTest("totest3", "select3 "); |
| 70 |
doTest("totest4", "select4 "); |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
</script> |
| 76 |
</head> |
| 77 |
<body onload="runTests()"> |
| 78 |
|
| 79 |
<p> |
| 80 |
This tests that double-clicking a word that follows newline and span |
| 81 |
</p> |
| 82 |
|
| 83 |
<h3>minimum case</h3> |
| 84 |
<div style="width:10pt"> |
| 85 |
abcd efgh <b id="totest1">select1</b> |
| 86 |
</div> |
| 87 |
|
| 88 |
<h3>with another word after the span</h3> |
| 89 |
<div style="width:100pt"> |
| 90 |
abcd efgh ijkl mnop <b id="totest2">select2</b> nottoselect |
| 91 |
</div> |
| 92 |
|
| 93 |
<h3>with another word in same the span</h3> |
| 94 |
<div style="width:100pt"> |
| 95 |
abcd efgh ijkl mnop <b id="totest3">select3 not</b> notyet |
| 96 |
</div> |
| 97 |
|
| 98 |
<h3>with another word before the span, in the same line</h3> |
| 99 |
<div style="width:100pt"> |
| 100 |
abcd efgh ijkl mnop qrst <b id="totest4">select4</b> notyet |
| 101 |
</div> |
| 102 |
|
| 103 |
<pre id="log"> |
| 104 |
</pre> |
| 105 |
|
| 106 |
</body> |
| 107 |
</html> |