tor-browser

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

test_bug904810.html (2565B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=904810
      5 -->
      6 <head>
      7  <title>Test for Bug 904810</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=904810">Mozilla Bug 904810</a>
     14 <p id="display">
     15 <textarea dir="ltr" id="textarea904810">
     16 first line
     17 second line
     18 third line
     19 </textarea></p>
     20 <div id="content" style="display: none">
     21 </div>
     22 <pre id="test">
     23 <script type="application/javascript">
     24 
     25 /** Test for Bug 904810 */
     26 
     27 SimpleTest.waitForExplicitFinish();
     28 
     29 SimpleTest.waitForFocus(function test() {
     30  function shiftLeft(i) {
     31    for ( ; i > 0; --i)
     32      synthesizeKey("KEY_ArrowLeft", {shiftKey:true});
     33  }
     34 
     35  function shiftRight(i) {
     36    for ( ; i > 0; --i)
     37      synthesizeKey("KEY_ArrowRight", {shiftKey:true});
     38  }
     39 
     40  const isWindows = /WINNT/.test(SpecialPowers.OS);
     41  var textarea = document.getElementById('textarea904810');
     42  textarea.focus();
     43 
     44  // Testing KEY_ArrowDown with forward selection
     45  textarea.selectionStart = 1;
     46  textarea.selectionEnd = 1;
     47  shiftRight(7);
     48  synthesizeKey("KEY_ArrowDown");
     49  is(textarea.selectionStart, 19, "caret moved to next line below selection end");
     50  is(textarea.selectionEnd, 19, "caret moved to next line below selection end");
     51 
     52  // Testing KEY_ArrowDown with backward selection
     53  textarea.selectionStart = 8;
     54  textarea.selectionEnd = 8;
     55  shiftLeft(7);
     56  synthesizeKey("KEY_ArrowDown");
     57  is(textarea.selectionStart, 12, "caret moved to next line below selection start");
     58  is(textarea.selectionEnd, 12, "caret moved to next line below selection start");
     59 
     60  // Testing KEY_ArrowUp with forward selection
     61  textarea.selectionStart = 12;
     62  textarea.selectionEnd = 12;
     63  shiftRight(7);
     64  synthesizeKey("KEY_ArrowUp");
     65  var result = textarea.selectionEnd
     66  is(textarea.selectionStart, 8, "caret moved to previous line above selection end");
     67  is(textarea.selectionEnd, 8, "caret moved to previous line above selection end");
     68 
     69  // Testing KEY_ArrowUp with backward selection
     70  textarea.selectionStart = 19;
     71  textarea.selectionEnd = 19;
     72  shiftLeft(7);
     73  synthesizeKey("KEY_ArrowUp");
     74  var result = textarea.selectionEnd
     75  is(textarea.selectionStart, 1, "caret moved to previous line above selection start");
     76  is(textarea.selectionEnd, 1, "caret moved to previous line above selection start");
     77 
     78  SimpleTest.finish();
     79 });
     80 </script>
     81 </pre>
     82 </body>
     83 </html>