Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / pasteboard / paste-list-002.html
blob839ac626388c905bb38ed6b0e356f95384d2eadb
1 <html>
2 <script src=../editing.js></script>
3 <script>
5 function editingTest() {
6 // Select "beta" and "gamma".
7 moveSelectionForwardByLineCommand();
8 for (i = 0; i < 2; i++)
9 extendSelectionForwardByLineCommand();
10 copyCommand();
12 // Paste with the cursor right before "delta".
13 moveSelectionForwardByLineCommand();
14 pasteCommand();
16 // Verify that the cursor is in the right place (still before delta).
17 var selection = window.getSelection();
18 if (selection.baseNode.parentNode != document.getElementById("delta") ||
19 selection.baseOffset != 0 || !selection.isCollapsed)
20 throw "Wrong selection position on before paste.";
22 // Paste with the cursor at the end of "delta".
23 moveSelectionForwardByWordCommand();
24 pasteCommand();
26 // Verify that the cursor is in the right place (new list item after delta).
27 var selection = window.getSelection();
28 if (!selection.isCollapsed || selection.baseNode.value != "")
29 throw "Wrong selection position on after paste.";
32 </script>
33 <body>
34 <div contentEditable="true">
35 <p>Copy/pasting list items in a list. This test should be run with DRT for pasteboard access.</p>
36 <p id="results">FAIL</p>
37 <ul id="test">
38 <li>alpha</li>
39 <li>beta</li>
40 <li>gamma</li>
41 <li id="delta">delta</li>
42 </ul>
43 </div>
45 <script>
46 if (window.testRunner)
47 testRunner.dumpAsText();
49 var elem = document.getElementById("test");
50 var selection = window.getSelection();
51 selection.collapse(elem, 0);
52 editingTest();
54 // Rerun the test but have the source list be indented.
55 document.getElementById("test").innerHTML = "<li>alpha</li><ul><li>beta</li><li>gamma</li></ul><li id='delta'>delta</li>";
56 selection.collapse(elem, 0);
57 editingTest();
59 document.getElementById("results").innerText = "PASS: " + document.getElementById("test").innerHTML;
60 </script>
62 </body>
63 </html>