Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / pasteboard / paste-list-004.html
blobe10960246c88cdf95d8d23c50c87d021c6bd87ea
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>
4 <ul>
5 <li id="test">one two</li>
6 <li>three four</li>
7 <li><span style="background-color:green"><b>monsters walking cross the floor</b></span></li>
8 </ul>
10 <p id="results">FAIL</p>
11 </body>
12 <script src="../editing.js"></script>
13 <script>
14 function escapeHTML(text)
16 return text.replace(/&/g, "&amp;").replace(/</g, "&lt;");
19 function editingTest()
21 // Select the first list item.
22 extendSelectionForwardByLineCommand();
23 copyCommand();
25 // Place the cursor between "three" and "four".
26 moveSelectionForwardByLineCommand();
27 moveSelectionForwardByWordCommand();
29 pasteCommand();
31 // Place the cursor between "walking" and "cross"
32 moveSelectionForwardByLineCommand();
33 for (var i = 0; i < 2; ++i)
34 moveSelectionForwardByWordCommand();
36 pasteCommand();
38 // Verify that the list is as expected.
39 var listItems = document.getElementsByTagName("li");
40 var results = [
41 "one two",
42 "three",
43 "one two",
44 "four",
45 "monsters walking",
46 "one two",
47 "cross the floor"
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(/&nbsp;/g, "");
64 listItems[i].innerHTML += ": " + escapeHTML(listItems[i].innerHTML);
68 if (window.internals)
69 internals.settings.setEditingBehavior("mac");
70 runDumpAsTextEditingTest(false);
71 document.getElementById("results").innerText = "PASS";
72 </script>