tor-browser

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

test_bug426246.html (3198B)


      1 <!DOCTYPE html>
      2 <!--
      3 https://bugzilla.mozilla.org/show_bug.cgi?id=426246
      4 -->
      5 <html>
      6 <head>
      7  <title>Test for Bug 426246</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=426246">Mozilla Bug 426246</a>
     14 <p id="display"></p>
     15 <div id="content" style="display: none;">
     16 
     17 </div>
     18 
     19 <div contenteditable="true" id="contenteditable1">
     20  <p>first line</p>
     21  <p>this is the second line</p>
     22 </div>
     23 
     24 <div contenteditable="true" id="contenteditable2">first line<br>this is the second line</div>
     25 <div contenteditable="true" id="contenteditable3"><ul><li>first line</li><li>this is the second line</li></ul></div>
     26 <pre contenteditable="true" id="contenteditable4">first line
     27 this is the second line</pre>
     28 
     29 <pre id="test">
     30 
     31 <script class="testbody" type="application/javascript">
     32 SimpleTest.waitForExplicitFinish();
     33 SimpleTest.waitForFocus(function() {
     34  let elm1 = document.getElementById("contenteditable1");
     35  elm1.focus();
     36  window.getSelection().collapse(elm1.lastElementChild.firstChild, "this is the ".length);
     37  SpecialPowers.doCommand(window, "cmd_deleteToBeginningOfLine");
     38  is(elm1.firstElementChild.textContent, "first line", "two paragraphs: the first line should stay untouched");
     39  is(elm1.lastElementChild.textContent, "second line", "two paragraphs: the characters after the caret should remain");
     40 
     41  let elm2 = document.getElementById("contenteditable2");
     42  elm2.focus();
     43  window.getSelection().collapse(elm2.lastChild, "this is the ".length);
     44  is(elm2.lastChild.textContent, "this is the second line", "br: correct initial content");
     45  SpecialPowers.doCommand(window, "cmd_deleteToBeginningOfLine");
     46  is(elm2.firstChild.textContent, "first line", "br: the first line should stay untouched");
     47  is(elm2.lastChild.textContent, "second line", "br: the characters after the caret should remain");
     48 
     49  let elm3 = document.getElementById("contenteditable3");
     50  elm3.focus();
     51  let firstLineLI = elm3.querySelector("li:first-child");
     52  let secondLineLI = elm3.querySelector("li:last-child");
     53  window.getSelection().collapse(secondLineLI.firstChild, "this is the ".length);
     54  is(secondLineLI.textContent, "this is the second line", "li: correct initial content");
     55  SpecialPowers.doCommand(window, "cmd_deleteToBeginningOfLine");
     56  is(firstLineLI.textContent, "first line", "li: the first line should stay untouched");
     57  is(secondLineLI.textContent, "second line", "li: the characters after the caret should remain");
     58 
     59  let elm4 = document.getElementById("contenteditable4");
     60  elm4.focus();
     61  window.getSelection().collapse(elm4.firstChild, "first line\nthis is the ".length);
     62  is(elm4.textContent, "first line\nthis is the second line", "pre: correct initial content");
     63  SpecialPowers.doCommand(window, "cmd_deleteToBeginningOfLine");
     64  is(elm4.textContent, "first line\nsecond line", "pre: the first line should stay untouched and the characters after the caret in the second line should remain");
     65 
     66  SimpleTest.finish();
     67 });
     68 </script>
     69 </pre>
     70 </body>
     71 </html>