blob: f014da19e74e63074cfc77f8a31850a1daa27e6d [file] [log] [blame]
<html>
<script src=../editing.js></script>
<script>
function editingTest() {
// Select "beta" and "gamma".
moveSelectionForwardByLineCommand();
for (i = 0; i < 2; i++)
extendSelectionForwardByLineCommand();
copyCommand();
// Paste with the cursor right before "delta".
moveSelectionForwardByLineCommand();
pasteCommand();
// Verify that the cursor is in the right place (still before delta).
var selection = window.getSelection();
if (selection.baseNode.parentNode != document.getElementById("delta") ||
selection.baseOffset != 0 || !selection.isCollapsed)
throw "Wrong selection position on before paste.";
// Paste with the cursor at the end of "delta".
moveSelectionForwardByWordCommand();
pasteCommand();
// Verify that the cursor is in the right place (new list item after delta).
var selection = window.getSelection();
if (!selection.isCollapsed || selection.baseNode.value != "")
throw "Wrong selection position on after paste.";
}
</script>
<body>
<div contentEditable="true">
<p>Copy/pasting list items in a list. This test should be run with DRT for pasteboard access.</p>
<p id="results">FAIL</p>
<ul id="test">
<li>alpha</li>
<li>beta</li>
<li>gamma</li>
<li id="delta">delta</li>
</ul>
</div>
<script>
if (window.testRunner)
testRunner.dumpAsText();
var elem = document.getElementById("test");
var selection = window.getSelection();
selection.setPosition(elem, 0);
editingTest();
// Rerun the test but have the source list be indented.
document.getElementById("test").innerHTML = "<li>alpha</li><ul><li>beta</li><li>gamma</li></ul><li id='delta'>delta</li>";
selection.setPosition(elem, 0);
editingTest();
document.getElementById("results").innerText = "PASS: " + document.getElementById("test").innerHTML;
</script>
</body>
</html>