tor-browser

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

test_bug597331.html (2027B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=597331
      5 -->
      6 <head>
      7  <title>Test for Bug 597331</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <script src="/tests/SimpleTest/EventUtils.js"></script>
     10  <script src="/tests/SimpleTest/WindowSnapshot.js"></script>
     11  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     12  <style>
     13  textarea { border-color: white; }
     14  </style>
     15 </head>
     16 <body>
     17 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=597331">Mozilla Bug 597331</a>
     18 <p id="display"></p>
     19 <div id="content">
     20 <textarea>line1
     21 line2
     22 line3
     23 </textarea>
     24 </div>
     25 <pre id="test">
     26 <script type="application/javascript">
     27 
     28 /** Test for Bug 597331 */
     29 
     30 SimpleTest.waitForExplicitFinish();
     31 addLoadEvent(function() {
     32  SimpleTest.executeSoon(function() {
     33    var t = document.querySelector("textarea");
     34    t.focus();
     35    t.selectionStart = 4;
     36    t.selectionEnd = 4;
     37    SimpleTest.executeSoon(function() {
     38      t.getBoundingClientRect(); // flush layout
     39      var before = snapshotWindow(window, true);
     40      t.selectionStart = 5;
     41      t.selectionEnd = 5;
     42      t.addEventListener("keydown", function() {
     43        SimpleTest.executeSoon(function() {
     44          t.style.display = "block";
     45          document.body.offsetWidth;
     46          t.style.display = "";
     47          document.body.offsetWidth;
     48 
     49          is(t.selectionStart, 4, "Cursor should be moved correctly");
     50          is(t.selectionEnd, 4, "Cursor should be moved correctly");
     51 
     52          var after = snapshotWindow(window, true);
     53 
     54          var result = compareSnapshots(before, after, true);
     55          var msg = "The caret should be displayed correctly after reframing";
     56          if (!result[0]) {
     57            msg += "\nRESULT:\n" + result[2];
     58            msg += "\nREFERENCE:\n" + result[1];
     59          }
     60          ok(result[0], msg);
     61 
     62          SimpleTest.finish();
     63        });
     64      }, {once: true});
     65      synthesizeKey("KEY_ArrowLeft");
     66    });
     67  });
     68 });
     69 
     70 </script>
     71 </pre>
     72 </body>
     73 </html>