editor/libeditor/html/tests/test_bug592592.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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 type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    10   <script type="text/javascript" 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   synthesizeKey(" ", {});
    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   synthesizeKey(" ", {});
    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("VK_BACK_SPACE", {});
    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>

mercurial