Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / inserting / insert-paragraph-separator-in-paragraph-in-list.html
blob6e19621d937c989d536a4af40d05d8197d13b5b7
1 <div id="container">
2 <p id="description"></p>
3 <div id="sample" contenteditable="true">
4 <ul>
5 <li><p>This</p></li>
6 <li><p>is</p></li>
7 <li><p>a</p></li>
8 <li><p>list</p></li>
9 </ul>
10 </div>
11 </div>
12 <script src="../../resources/js-test.js"></script>
13 <script>
14 function $(id) { return document.getElementById(id); }
16 var actualHTML;
17 var selection = getSelection();
19 function testIt(nth, message, expectedText, expectedHTML, initRange, getResult)
21 var listItem = $('sample').querySelectorAll('li')[nth];
22 var range = document.createRange();
23 initRange(listItem, range);
24 selection.removeAllRanges();
25 selection.addRange(range);
26 document.execCommand('InsertText', false, '\n');
27 debug(message);
28 actualHTML = getResult(listItem).outerHTML;
29 shouldBeEqualToString('actualHTML', expectedHTML);
30 shouldBeEqualToString('selection.type', 'Caret');
31 shouldBeEqualToString('selection.focusNode.textContent', expectedText);
32 shouldBe('selection.focusOffset', '0');
33 debug('\n');
36 $('sample').focus();
38 testIt(2, 'insert at end', '', '<li><p><br></p></li>',
39 function(listChild, range) {
40 var textNode = listChild.firstChild.firstChild;
41 range.setStart(textNode, textNode.nodeValue.length);
43 function(listItem) {
44 return listItem.nextElementSibling;
45 });
47 testIt(1, 'insert at start', 'is', '<li><p><br></p></li>',
48 function(listChild, range) {
49 var textNode = listChild.firstChild.firstChild;
50 range.setStart(textNode, 0);
52 function(listItem) {
53 return listItem.previousElementSibling;
54 });
56 testIt(0, 'insert at middle', 'his', '<li><p>his</p></li>',
57 function(listChild, range) {
58 var textNode = listChild.firstChild.firstChild;
59 range.setStart(textNode, 1);
61 function(listItem) {
62 return listItem.nextElementSibling;
63 });
65 if (window.testRunner)
66 $('container').outerHTML = '';
67 </script>