tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug592592.html (1933B)


      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">
     21 
     22 /** Test for Bug 592592 */
     23 
     24 SimpleTest.waitForExplicitFinish();
     25 SimpleTest.waitForFocus(function() {
     26  var ed = document.getElementById("editor");
     27 
     28  // Put the selection right after "a"
     29  ed.focus();
     30  window.getSelection().collapse(ed.firstChild, 1);
     31 
     32  // Press space
     33  sendString(" ");
     34 
     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");
     37 
     38  // Remove the preformatted style
     39  ed.removeAttribute("style");
     40 
     41  // Reset the DOM
     42  ed.innerHTML = "a b";
     43 
     44  // Reset the selection
     45  ed.focus();
     46  window.getSelection().collapse(ed.firstChild, 1);
     47 
     48  // Press space
     49  sendString(" ");
     50 
     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");
     53 
     54  ed = document.getElementById("editor2");
     55 
     56  // Put the selection after the second space in the second editable field
     57  ed.focus();
     58  window.getSelection().collapse(ed.firstChild, 3);
     59 
     60  // Press the back-space key
     61  synthesizeKey("KEY_Backspace");
     62 
     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");
     65 
     66  SimpleTest.finish();
     67 });
     68 
     69 </script>
     70 </pre>
     71 </body>
     72 </html>