4 <script src=
"../../resources/js-test.js"></script>
7 <div id=editor contenteditable
></div>
9 shouldBeTrue("document.queryCommandEnabled('DefaultParagraphSeparator')");
10 shouldBeEqualToString("document.queryCommandValue('DefaultParagraphSeparator')", "div"); // Default is div.
11 evalAndLog("document.execCommand('DefaultParagraphSeparator', false, 'p')");
12 shouldBeEqualToString("document.queryCommandValue('DefaultParagraphSeparator')", "p");
13 evalAndLog("document.execCommand('DefaultParagraphSeparator', false, 'br')");
14 shouldBeEqualToString("document.queryCommandValue('DefaultParagraphSeparator')", "p");
15 evalAndLog("document.execCommand('DefaultParagraphSeparator', false, 'invalid')");
16 shouldBeEqualToString("document.queryCommandValue('DefaultParagraphSeparator')", "p");
18 debug("\nCreating paragraphs in the normal way.");
19 var div
= document
.querySelector("#editor");
21 evalAndLog("document.execCommand('InsertText', false, 'a')");
22 shouldBeEqualToString("div.innerHTML", "a");
23 evalAndLog("document.execCommand('InsertText', false, '\\n')");
24 shouldBeEqualToString("div.innerHTML", "a<p><br></p>");
25 evalAndLog("document.execCommand('InsertText', false, 'b')");
26 shouldBeEqualToString("div.innerHTML", "a<p>b</p>");
27 evalAndLog("document.execCommand('InsertText', false, '\\n')");
28 shouldBeEqualToString("div.innerHTML", "a<p>b</p><p><br></p>");
29 evalAndLog("document.execCommand('Delete')");
30 shouldBeEqualToString("div.innerHTML", "a<p>b</p>");
31 evalAndLog("document.execCommand('Delete')");
32 shouldBeEqualToString("div.innerHTML", "a<p><br></p>");
33 evalAndLog("document.execCommand('Delete')");
34 shouldBeEqualToString("div.innerHTML", "a");
35 evalAndLog("document.execCommand('DefaultParagraphSeparator', false, 'div')");
36 evalAndLog("document.execCommand('InsertParagraph')");
37 shouldBeEqualToString("div.innerHTML", "a<div><br></div>");
38 evalAndLog("div.innerHTML = ''");
40 debug("\nUsing the previous block as template for the new one.");
41 evalAndLog("document.execCommand('DefaultParagraphSeparator', false, 'p')");
42 debug('document.execCommand("InsertHTML", false, "<pre>a</pre>");');
43 document
.execCommand("InsertHTML", false, "<pre>a</pre>");
44 shouldBeEqualToString("div.innerHTML", "<pre>a</pre>");
45 evalAndLog("document.execCommand('InsertText', false, 'b')");
46 shouldBeEqualToString("div.innerHTML", "<pre>ab</pre>");
47 evalAndLog("document.execCommand('InsertText', false, '\\n')");
48 shouldBeEqualToString("div.innerHTML", "<pre>ab</pre><pre><br></pre>");
49 evalAndLog("document.execCommand('InsertText', false, 'c')");
50 shouldBeEqualToString("div.innerHTML", "<pre>ab</pre><pre>c</pre>");
51 evalAndLog("document.execCommand('DefaultParagraphSeparator', false, 'div')");
52 evalAndLog("document.execCommand('InsertText', false, '\\n')");
53 shouldBeEqualToString("div.innerHTML", "<pre>ab</pre><pre>c</pre><pre><br></pre>");
54 evalAndLog("document.execCommand('Delete')");
55 evalAndLog("document.execCommand('InsertParagraph')");
56 shouldBeEqualToString("div.innerHTML", "<pre>ab</pre><pre>c</pre><pre><br></pre>");
58 debug("\nBreaking out of lists.");
59 evalAndLog("div.innerHTML = ''");
60 evalAndLog("document.execCommand('DefaultParagraphSeparator', false, 'p')");
61 debug('document.execCommand("InsertHTML", false, "<ul><li>a</li></ul>")');
62 document
.execCommand("InsertHTML", false, "<ul><li>a</li></ul>");
63 shouldBeEqualToString("div.innerHTML", "<ul><li>a</li></ul>");
64 evalAndLog("document.execCommand('InsertParagraph')");
65 evalAndLog("document.execCommand('InsertParagraph')");
66 shouldBeEqualToString("div.innerHTML", "<ul><li>a</li></ul><p><br></p>");
68 debug("\nBreaking up nested elements.");
69 evalAndLog("div.innerHTML = ''");
70 debug('document.execCommand("InsertHTML", false, "<cite>a<cite>bc</cite></cite>")');
71 document
.execCommand("InsertHTML", false, "<cite>a<cite>bc</cite></cite>");
72 evalAndLog('window.getSelection().modify("move", "backward", "character")');
73 evalAndLog("document.execCommand('InsertParagraph')");
74 shouldBeEqualToString("div.innerHTML", "<cite>a<cite>b</cite></cite><p><cite><cite>c</cite></cite></p>");