tor-browser

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

test_bug1361008.html (1936B)


      1 <!DOCTYPE html>
      2 <!--
      3 https://bugzilla.mozilla.org/show_bug.cgi=id=1361008
      4 -->
      5 <html>
      6  <head>
      7    <title>Bug 1361008</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=1361008">Mozilla Bug 1361008</a>
     14 <p id="display"></p>
     15 <div contenteditable="true" id="edit1">
     16  <br>
     17 </div>
     18 <div contenteditable="true" id="edit2">
     19  <br>
     20 </div>
     21 <pre id="test">
     22 <script type="application/javascript">
     23 SimpleTest.waitForExplicitFinish();
     24 SimpleTest.waitForFocus(() => {
     25  document.execCommand("defaultparagraphseparator", false, "div");
     26  let edit1 = document.getElementById("edit1");
     27  edit1.focus();
     28  let selection = window.getSelection();
     29  // Insert text before BR element
     30  selection.collapse(edit1, 0);
     31  sendString("AB");
     32  synthesizeKey("KEY_Enter");
     33  // count <div> element into contenteidable
     34  is(edit1.getElementsByTagName("div").length, 2,
     35     "DIV element should be 2 children");
     36  is(edit1.getElementsByTagName("div")[0].innerText,
     37     "AB", "AB should be in 1st DIV element");
     38  is(edit1.getElementsByTagName("div")[1].innerHTML,
     39     "<br>", "BR element should be in 2nd DIV element");
     40 
     41  document.execCommand("defaultparagraphseparator", false, "p");
     42  let edit2 = document.getElementById("edit2");
     43  edit2.focus();
     44  selection.collapse(edit2, 0);
     45  // Insert text before BR element
     46  sendString("AB");
     47  synthesizeKey("KEY_Enter");
     48 
     49  is(edit2.getElementsByTagName("p").length, 2,
     50     "P element should be 2 children");
     51  is(edit2.getElementsByTagName("p")[0].innerText,
     52     "AB", "AB should be in 1st P element");
     53  is(edit2.getElementsByTagName("p")[1].innerHTML,
     54     "<br>", "BR element should be into 2nd P element");
     55 
     56  SimpleTest.finish();
     57 });
     58 </script>
     59 </pre>
     60 </body>
     61 </html>