1 <body contentEditable="true">
2 <p>Pasting a list item into the middle of another list item should split the target list
3 item into two with the pasted content in between.</p>
5 <li id="test">one two</li>
7 <li><span style="background-color:green"><b>monsters walking cross the floor</b></span></li>
10 <p id="results">FAIL</p>
12 <script src="../editing.js"></script>
14 function escapeHTML(text)
16 return text.replace(/&/g, "&").replace(/</g, "<");
19 function editingTest()
21 // Select the first list item.
22 extendSelectionForwardByLineCommand();
25 // Place the cursor between "three" and "four".
26 moveSelectionForwardByLineCommand();
27 moveSelectionForwardByWordCommand();
31 // Place the cursor between "walking" and "cross"
32 for (var i = 0; i < 2; ++i)
33 moveSelectionForwardByLineCommand();
34 for (var i = 0; i < 2; ++i)
35 moveSelectionForwardByWordCommand();
39 // Verify that the list is as expected.
40 var listItems = document.getElementsByTagName("li");
52 if (listItems.length != 9)
53 throw "Expected 8 list items, found " + listItems.length;
54 for (var i = 0; i < results.length; ++i) {
55 var actual = listItems[i].innerText.replace(/^\s+/g, "");
56 if (results[i] != actual)
57 throw "Unexpected list item: " + i + "," + results[i] + "," + listItems[i].innerText;
60 // Verify that the cursor is in the right place (on the blank line).
61 var selection = window.getSelection();
62 if (selection.baseNode != listItems[7] || selection.baseOffset != 0 || !selection.isCollapsed)
63 throw "Wrong selection position";
65 for (var i = 0; i < listItems.length; ++i) {
66 listItems[i].innerHTML = listItems[i].innerHTML.replace(/ /g, "");
67 listItems[i].innerHTML += ": " + escapeHTML(listItems[i].innerHTML);
71 runDumpAsTextEditingTest(false);
72 document.getElementById("results").innerText = "PASS";