3 https://bugzilla.mozilla.org/show_bug.cgi?id=426246
7 <title>Test for Bug
426246</title>
8 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
9 <script src=
"/tests/SimpleTest/EventUtils.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
13 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=426246">Mozilla Bug
426246</a>
15 <div id=
"content" style=
"display: none;">
19 <div contenteditable=
"true" id=
"contenteditable1">
21 <p>this is the second line
</p>
24 <div contenteditable=
"true" id=
"contenteditable2">first line
<br>this is the second line
</div>
25 <div contenteditable=
"true" id=
"contenteditable3"><ul><li>first line
</li><li>this is the second line
</li></ul></div>
26 <pre contenteditable=
"true" id=
"contenteditable4">first line
27 this is the second line
</pre>
31 <script class=
"testbody" type=
"application/javascript">
32 SimpleTest.waitForExplicitFinish();
33 SimpleTest.waitForFocus(function() {
34 let elm1 = document.getElementById(
"contenteditable1");
36 window.getSelection().collapse(elm1.lastElementChild.firstChild,
"this is the ".length);
37 SpecialPowers.doCommand(window,
"cmd_deleteToBeginningOfLine");
38 is(elm1.firstElementChild.textContent,
"first line",
"two paragraphs: the first line should stay untouched");
39 is(elm1.lastElementChild.textContent,
"second line",
"two paragraphs: the characters after the caret should remain");
41 let elm2 = document.getElementById(
"contenteditable2");
43 window.getSelection().collapse(elm2.lastChild,
"this is the ".length);
44 is(elm2.lastChild.textContent,
"this is the second line",
"br: correct initial content");
45 SpecialPowers.doCommand(window,
"cmd_deleteToBeginningOfLine");
46 is(elm2.firstChild.textContent,
"first line",
"br: the first line should stay untouched");
47 is(elm2.lastChild.textContent,
"second line",
"br: the characters after the caret should remain");
49 let elm3 = document.getElementById(
"contenteditable3");
51 let firstLineLI = elm3.querySelector(
"li:first-child");
52 let secondLineLI = elm3.querySelector(
"li:last-child");
53 window.getSelection().collapse(secondLineLI.firstChild,
"this is the ".length);
54 is(secondLineLI.textContent,
"this is the second line",
"li: correct initial content");
55 SpecialPowers.doCommand(window,
"cmd_deleteToBeginningOfLine");
56 is(firstLineLI.textContent,
"first line",
"li: the first line should stay untouched");
57 is(secondLineLI.textContent,
"second line",
"li: the characters after the caret should remain");
59 let elm4 = document.getElementById(
"contenteditable4");
61 window.getSelection().collapse(elm4.firstChild,
"first line\nthis is the ".length);
62 is(elm4.textContent,
"first line\nthis is the second line",
"pre: correct initial content");
63 SpecialPowers.doCommand(window,
"cmd_deleteToBeginningOfLine");
64 is(elm4.textContent,
"first line\nsecond line",
"pre: the first line should stay untouched and the characters after the caret in the second line should remain");