1 description("This tests CompositeEditCommand::breakOutOfEmptyListItem by inserting new paragraph")
3 var testContainer
= document
.createElement("div");
4 testContainer
.contentEditable
= true;
5 document
.body
.appendChild(testContainer
);
10 var ev
= document
.createEvent("KeyboardEvent");
11 ev
.initKeyEvent("keypress", true, true, window
, 0,0,0,0, 0, key
.charCodeAt(0));
12 document
.body
.dispatchEvent(ev
);
15 var ev
= document
.createEvent("TextEvent");
16 ev
.initTextEvent('textInput', true, true, null, key
.charAt(0));
17 document
.body
.dispatchEvent(ev
);
21 function enterAtTarget(initialContent
)
23 testContainer
.innerHTML
= initialContent
;
24 var r
= document
.createRange();
25 var s
= window
.getSelection();
27 var t
= document
.getElementById('target');
29 return 'target element not found';
37 return testContainer
.innerHTML
;
40 function testBreakOutOfEmptyListItem(initialContents
, expectedContents
)
42 shouldBe("enterAtTarget('"+initialContents
+"')", "'"+expectedContents
+"'");
45 testBreakOutOfEmptyListItem('<ul><li>a <ul><li>b</li><li id="target"></li></ul> </li></ul>', '<ul><li>a </li><ul><li>b</li></ul><li><br></li> </ul>');
46 testBreakOutOfEmptyListItem('<ul><li>a <ul><li id="target"></li><li>b</li></ul> </li></ul>', '<ul><li>a </li><li><br></li><ul><li>b</li></ul> </ul>');
47 testBreakOutOfEmptyListItem('<ul><li>a <ul><li>b</li><li id="target"></li><li>c</li></ul> </li></ul>', '<ul><li>a </li><ul><li>b</li></ul><li><br></li><ul><li>c</li></ul> </ul>');
48 testBreakOutOfEmptyListItem('<ul><li>hello<ul><li id="target"><br></li></ul>world</li></ul>', '<ul><li>hello<div><br></div>world</li></ul>');
49 testBreakOutOfEmptyListItem('<ul><li>hello<ul><li id="target"><br></li></ul></li></ul>', '<ul><li>hello</li><li><br></li></ul>');
50 testBreakOutOfEmptyListItem('<ul><li><ul><li id="target"><br></li></ul>world</li></ul>', '<ul><li><div><br></div>world</li></ul>');
51 testBreakOutOfEmptyListItem('<ul><li><ul><li id="target"><br></li></ul></li></ul>', '<ul><li></li><li><br></li></ul>');
52 testBreakOutOfEmptyListItem('<ul><li>hello</li><br id="target"></ul>', '<ul><li>hello</li></ul><div><br></div>');
53 testBreakOutOfEmptyListItem('<ul><br id="target"></ul>', '<div><br></div>');
54 testBreakOutOfEmptyListItem('<ul><li>hello</li>abc<li id="target"></li></ul>', '<ul><li>hello</li>abc</ul><div><br></div>');
55 testBreakOutOfEmptyListItem('<ul><li>1</li><ul><li>2.1</li></ul><li id="target"></li></ul>', '<ul><li>1</li><ul><li>2.1</li></ul></ul><div><br></div>');
56 testBreakOutOfEmptyListItem('<ul><li>1</li><ul><li>2.1</li><li>2.2</li><li id="target"></li></ul><li>3</li></ul>', '<ul><li>1</li><ul><li>2.1</li><li>2.2</li></ul><li><br></li><li>3</li></ul>');
57 testBreakOutOfEmptyListItem('<ul><li>1</li><ul><li>2.1</li><li>2.2</li>abc<li id="target"></li></ul><li>3</li></ul>', '<ul><li>1</li><ul><li>2.1</li><li>2.2</li>abc</ul><li><br></li><li>3</li></ul>');
58 testBreakOutOfEmptyListItem('<ul><li>1</li><li id="target"></li><li>3</li></ul>', '<ul><li>1</li></ul><div><br></div><ul><li>3</li></ul>');
60 document
.body
.removeChild(testContainer
);
62 var successfullyParsed
= true;