Bug 1772588 [wpt PR 34302] - [wpt] Add test for block-in-inline offsetParent., a...
[gecko.git] / editor / libeditor / tests / test_bug1385905.html
blobfda99ae7410fbfe169ddbbe7d455fb786a040b7b
1 <!DOCTYPE html>
2 <!--
3 https://bugzilla.mozilla.org/show_bug.cgi=id=1385905
4 -->
5 <html>
6 <head>
7 <script src="/tests/SimpleTest/SimpleTest.js"></script>
8 <script src="/tests/SimpleTest/EventUtils.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
10 </head>
11 <body>
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1385905">Mozilla Bug 1385905</a>
13 <div id="display"></div>
14 <div id="editor" contenteditable style="padding: 5px;"><div>contents</div></div>
15 <pre id="test">
16 </pre>
18 <script class="testbody" type="application/javascript">
19 SimpleTest.waitForExplicitFinish();
20 SimpleTest.waitForFocus(() => {
21 function ensureNoPaddingBR() {
22 for (let br of document.querySelectorAll("#editor > div > br")) {
23 ok(!SpecialPowers.wrap(br).isPaddingForEmptyLastLine,
24 "padding <br> element shouldn't be used with this test");
27 document.execCommand("defaultparagraphseparator", false, "div");
28 var editor = document.getElementById("editor");
29 // Click the left blank area of the first line to set cursor to the start of "contents".
30 synthesizeMouse(editor, 3, 10, {});
31 synthesizeKey("KEY_Enter");
32 is(editor.innerHTML, "<div><br></div><div>contents</div>",
33 "Typing Enter at start of the <div> element should split the <div> element");
34 synthesizeKey("KEY_ArrowUp");
35 sendString("x");
36 is(editor.innerHTML, "<div>x<br></div><div>contents</div>",
37 "Typing 'x' at the empty <div> element should just insert 'x' into the <div> element");
38 ensureNoPaddingBR();
39 synthesizeKey("KEY_Enter");
40 is(editor.innerHTML, "<div>x</div><div><br></div><div>contents</div>",
41 "Typing Enter next to 'x' in the first <div> element should split the <div> element and inserts <br> element to a new <div> element");
42 ensureNoPaddingBR();
43 synthesizeKey("KEY_Enter");
44 is(editor.innerHTML, "<div>x</div><div><br></div><div><br></div><div>contents</div>",
45 "Typing Enter in the empty <div> should split the <div> element and inserts <br> element to a new <div> element");
46 ensureNoPaddingBR();
47 SimpleTest.finish();
48 });
49 </script>
50 </body>
51 </html>