4 https://bugzilla.mozilla.org/show_bug.cgi?id=1330796
8 <title>Test for Bug
772796</title>
9 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <script src=
"/tests/SimpleTest/EventUtils.js"></script>
11 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
12 <style> .pre { white-space: pre }
</style>
15 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=772796">Mozilla Bug
1330796</a>
17 <div id=
"content" style=
"display: none">
20 <div id=
"editable" contenteditable
></div>
24 <script type=
"application/javascript">
25 // We want to test what happens when the user splits a mail cite by clicking
26 // at the start, the middle and the end of the cite and hitting the enter key.
27 // Mail cites are spans, and since bug
1288911 they are displayed as blocks.
28 // The _moz_quote attribute is used to give the cite a blue color via CSS.
29 // As an internal attribute, it's not returned from the innerHTML.
30 // To the user the tests look like:
32 // This text is
10 characters long, so we position at
0,
5 and
10.
33 // Althought since bug
1288911 those cites are displayed as block,
34 // the tests are repeated also for inline display.
35 // Each entry of the 'tests' array has the original HTML, the offset to click
36 // at and the expected result HTML.
38 // With
style=
"display: block;".
39 [
"<span _moz_quote=true style=\"display: block;\
">> mailcite<br></span>",
0,
40 "x<br><span style=\"display: block;\
">> mailcite<br></span>" ],
41 [
"<span _moz_quote=true style=\"display: block;\
">> mailcite<br></span>",
5,
42 "<span style=\"display: block;\
">> mai<br></span>x<br><span style=\"display: block;\
">lcite<br></span>"],
43 [
"<span _moz_quote=true style=\"display: block;\
">> mailcite<br></span>",
10,
44 "<span style=\"display: block;\
">> mailcite<br></span>x<br>" ],
45 // No
<br> at the end to simulate prior deletion to the end of the quote.
46 [
"<span _moz_quote=true style=\"display: block;\
">> mailcite</span>",
10,
47 "<span style=\"display: block;\
">> mailcite<br></span>x<br>" ],
49 // Without
style=
"display: block;".
50 [
"<span _moz_quote=true>> mailcite<br></span>",
0,
51 "x<br><span>> mailcite<br></span>" ],
52 [
"<span _moz_quote=true>> mailcite<br></span>",
5,
53 "<span>> mai</span><br>x<br><span>lcite<br></span>" ],
54 [
"<span _moz_quote=true>> mailcite<br></span>",
10,
55 "<span>> mailcite<br></span>x<br>" ],
56 // No
<br> at the end to simulate prior deletion to the end of the quote.
57 [
"<span _moz_quote=true>> mailcite</span>",
10,
58 "<span>> mailcite</span><br>x<br>" ],
61 /** Test for Bug
1330796 **/
63 SimpleTest.waitForExplicitFinish();
65 SimpleTest.waitForFocus(function() {
66 var sel = window.getSelection();
67 var theEdit = document.getElementById(
"editable");
70 for (let i =
0; i < tests.length; i++) {
71 theEdit.innerHTML = tests[i][
0];
73 var theText = theEdit.firstChild.firstChild;
74 // Position set at the beginning , middle and end of the text.
75 sel.collapse(theText, tests[i][
1]);
77 synthesizeKey(
"KEY_Enter");
79 is(theEdit.innerHTML, tests[i][
2],
"unexpected HTML for test " + i.toString());
85 function makeMailEditor() {
86 var Ci = SpecialPowers.Ci;
87 var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
88 var editor = editingSession.getEditorForWindow(window);
89 editor.flags |= Ci.nsIEditor.eEditorMailMask;