Bug 1772588 [wpt PR 34302] - [wpt] Add test for block-in-inline offsetParent., a...
[gecko.git] / editor / libeditor / tests / test_bug592592.html
blobc1a74e989351e491642767c3aab6e9f7a18d0d58
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=592592
5 -->
6 <head>
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>
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=592592">Mozilla Bug 592592</a>
14 <p id="display"></p>
15 <div id="content">
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>
18 </div>
19 <pre id="test">
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"
29 ed.focus();
30 window.getSelection().collapse(ed.firstChild, 1);
32 // Press space
33 sendString(" ");
35 // Make sure we haven't added an nbsp
36 is(ed.innerHTML, "a b", "We should not be adding an &nbsp; for preformatted text");
38 // Remove the preformatted style
39 ed.removeAttribute("style");
41 // Reset the DOM
42 ed.innerHTML = "a b";
44 // Reset the selection
45 ed.focus();
46 window.getSelection().collapse(ed.firstChild, 1);
48 // Press space
49 sendString(" ");
51 // Make sure that we have added an nbsp
52 is(ed.innerHTML, "a&nbsp; b", "We should add an &nbsp; for non-preformatted text");
54 ed = document.getElementById("editor2");
56 // Put the selection after the second space in the second editable field
57 ed.focus();
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");
66 SimpleTest.finish();
67 });
69 </script>
70 </pre>
71 </body>
72 </html>