1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
<!DOCTYPE html>
<html>
<head>
<title>Test "insertParagraph" command in inline editing host</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
</head>
<body>
<span contenteditable>foobar</span>
<hr>
<p><span contenteditable>foobar</span></p>
<hr>
<div><span contenteditable>foobar</span></div>
<hr>
<div contenteditable><p contenteditable="false"><span contenteditable>foobar</span></p></div>
<p id="display">
</p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(() => {
var selection = document.getSelection();
var editors = document.querySelectorAll("span[contenteditable]");
var editor = editors.item(0);
editor.focus();
selection.collapse(editor.firstChild, 3);
document.execCommand("insertParagraph", false);
is(editor.innerHTML, "foo<br>bar",
"insertParagraph should insert <br> element (inline editing host is in <body>)");
editor = editors.item(1);
editor.focus();
selection.collapse(editor.firstChild, 3);
document.execCommand("insertParagraph", false);
is(editor.parentNode.innerHTML, "<span contenteditable=\"\">foo<br>bar</span>",
"insertParagraph should insert <br> element (inline editing host is in <p>)");
editor = editors.item(2);
editor.focus();
selection.collapse(editor.firstChild, 3);
document.execCommand("insertParagraph", false);
is(editor.parentNode.innerHTML, "<span contenteditable=\"\">foo<br>bar</span>",
"insertParagraph should insert <br> element (inline editing host is in <div>)");
editor = editors.item(3);
editor.focus();
selection.collapse(editor.firstChild, 3);
document.execCommand("insertParagraph", false);
is(editor.parentNode.parentNode.innerHTML, "<p contenteditable=\"false\"><span contenteditable=\"\">foo<br>bar</span></p>",
"insertParagraph should insert <br> element (inline editing host is in <p contenteditable=\"false\"> in <div contenteditable>)");
SimpleTest.finish();
});
</script>
</body>
</html>
|