tor-browser

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

test_bug1390562.html (2318B)


      1 <!DOCTYPE html>
      2 <!--
      3 https://bugzilla.mozilla.org/show_bug.cgi?id=1390562
      4 -->
      5 <html>
      6 <head>
      7  <title>Test for Bug 1390562</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <script src="/tests/SimpleTest/EventUtils.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     11 </head>
     12 <body>
     13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1390562">Mozilla Bug 1390562</a>
     14 <p id="display"></p>
     15 <div id="content" style="display: none;">
     16 
     17 </div>
     18 
     19 <div id="editor" contenteditable></div>
     20 <pre id="test">
     21 <script class="testbody" type="application/javascript">
     22 SimpleTest.waitForExplicitFinish();
     23 SimpleTest.waitForFocus(function() {
     24  let editor = document.getElementById("editor");
     25 
     26  editor.focus();
     27 
     28  // Make the HTML editor's default break is <br>
     29  document.execCommand("defaultParagraphSeparator", false, "br");
     30 
     31  editor.innerHTML = "<div>abc<br><br></div>def";
     32 
     33  // Collapse selection at the end of the first text node.
     34  window.getSelection().collapse(editor.firstChild.firstChild, 3);
     35 
     36  // Then, typing Enter should insert <br> for <div> container.
     37  // This is necessary for backward compatibility.  When we change default
     38  // value of "defaultParagraphSeparator" to "div" or "p", it may be possible
     39  // to remove this hack.
     40  synthesizeKey("KEY_Enter");
     41 
     42  is(editor.innerHTML,
     43     "<div>abc<br><br><br></div>def",
     44     "Enter key press at end of a text node followed by a visible <br> shouldn't split <div> container when defaultParagraphSeparator is 'br'");
     45 
     46  // Check also the case of <p> as container.
     47  editor.innerHTML = "<p>abc<br><br></p>def";
     48 
     49  // Collapse selection at the end of the first text node.
     50  window.getSelection().collapse(editor.firstChild.firstChild, 3);
     51 
     52  // Then, typing Enter should splitting <p> container and remove the visible
     53  // <br> element next to the caret position.
     54  // This is not consistent with <div> container, but this is better behavior
     55  // and keep using this behavior.
     56  synthesizeKey("KEY_Enter");
     57 
     58  is(editor.innerHTML,
     59     "<p>abc</p><p><br></p>def",
     60     "Enter key press at end of a text node followed by a visible <br> should split <p> container and remove the visible <br> when defaultParagraphSeparator is 'br'");
     61 
     62  SimpleTest.finish();
     63 });
     64 </script>
     65 </pre>
     66 </body>
     67 </html>