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 moveSelectionForwardByLineCommand();
33 for (var i
= 0; i
< 2; ++i
)
34 moveSelectionForwardByWordCommand();
38 // Verify that the list is as expected.
39 var listItems
= document
.getElementsByTagName("li");
49 if (listItems
.length
!= 7)
50 throw "Expected 7 list items, found " + listItems
.length
;
51 for (var i
= 0; i
< results
.length
; ++i
) {
52 var actual
= listItems
[i
].innerText
.replace(/^\s+/g, "");
53 if (results
[i
] != actual
)
54 throw "Unexpected list item: " + i
+ "," + results
[i
] + "," + listItems
[i
].innerText
;
57 // Verify that the cursor is in the right place (at the beginning of 'cross the floor').
58 var selection
= window
.getSelection();
59 if (selection
.baseNode
!= listItems
[6].firstChild
.firstChild
.firstChild
|| selection
.baseOffset
!= 0 || !selection
.isCollapsed
)
60 throw "Wrong selection position";
62 for (var i
= 0; i
< listItems
.length
; ++i
) {
63 listItems
[i
].innerHTML
= listItems
[i
].innerHTML
.replace(/ /g, "");
64 listItems
[i
].innerHTML
+= ": " + escapeHTML(listItems
[i
].innerHTML
);
69 internals
.settings
.setEditingBehavior("mac");
70 runDumpAsTextEditingTest(false);
71 document
.getElementById("results").innerText
= "PASS";