4 https://bugzilla.mozilla.org/show_bug.cgi?id=592592
7 <title>Test for Bug
592592</title>
8 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
10 <script src=
"/tests/SimpleTest/EventUtils.js"></script>
13 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=592592">Mozilla Bug
592592</a>
16 <div id=
"editor" contenteditable=
"true" style=
"white-space:pre-wrap">a b
</div>
17 <div id=
"editor2" contenteditable=
"true" style=
"white-space:pre-wrap">a b
</div>
20 <script type=
"application/javascript">
22 /** Test for Bug
592592 **/
24 SimpleTest.waitForExplicitFinish();
25 SimpleTest.waitForFocus(function() {
26 var ed = document.getElementById(
"editor");
28 // Put the selection right after
"a"
30 window.getSelection().collapse(ed.firstChild,
1);
35 // Make sure we haven't added an nbsp
36 is(ed.innerHTML,
"a b",
"We should not be adding an for preformatted text");
38 // Remove the preformatted style
39 ed.removeAttribute(
"style");
44 // Reset the selection
46 window.getSelection().collapse(ed.firstChild,
1);
51 // Make sure that we have added an nbsp
52 is(ed.innerHTML,
"a b",
"We should add an for non-preformatted text");
54 ed = document.getElementById(
"editor2");
56 // Put the selection after the second space in the second editable field
58 window.getSelection().collapse(ed.firstChild,
3);
60 // Press the back-space key
61 synthesizeKey(
"KEY_Backspace");
63 // Make sure that we've only deleted a single space
64 is(ed.innerHTML,
"a b",
"We should only be deleting a single space");