tor-browser

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

input-text-scroll-event-when-using-arrow-keys.html (2898B)


      1 <!doctype html>
      2 <html>
      3 <head>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script src="/resources/testdriver.js"></script>
      7 <script src="/resources/testdriver-actions.js"></script>
      8 <script src="/resources/testdriver-vendor.js"></script>
      9 
     10 </head>
     11 <body onload=runTest()>
     12    <p>Moving the cursor using the arrow keys into an
     13        input element fires scroll events when text has to scroll into view.
     14        Uses arrow keys to move forward and backwards in the input
     15        element.</p>
     16    <input type="text" style='width: 50px'
     17    value="Fooooooooooooooooooooooooooooooooooooooooooooooooo"/>
     18    <textarea rows="4" cols="4">
     19        Fooooooooooooooooooooooooooooooooooooooooooooooooo
     20    </textarea>
     21 
     22    <script>
     23      async function moveCursorRightInsideElement(element, value){
     24          var arrowRight = '\uE014';
     25          for(var i=0;i<value;i++){
     26            await test_driver.send_keys(element, arrowRight);
     27          }
     28      }
     29 
     30      function runTest(){
     31          promise_test(async(t) => { return new Promise(async (resolve, reject) => {
     32            var input = document.getElementsByTagName('input')[0];
     33            function handleScroll(){
     34              resolve("Scroll Event successfully fired!");
     35            }
     36            input.addEventListener('scroll', handleScroll, false);
     37            // move cursor to the right until the text scrolls
     38            while(input.scrollLeft === 0){
     39              await moveCursorRightInsideElement(input, 1);
     40            }
     41            // if there is no scroll event fired then test will fail by timeout
     42          })},
     43             /*
     44               Moving the cursor using the arrow keys into an input element
     45               fires scroll events when text has to scroll into view.
     46               Uses arrow keys to move right in the input element.
     47             */
     48           "Scroll event fired for <input> element.");
     49 
     50          promise_test(async(t) => { return new Promise(async (resolve, reject) => {
     51            var textarea = document.getElementsByTagName('textarea')[0];
     52            function handleScroll(){
     53              resolve("Scroll Event successfully fired!");
     54            }
     55            textarea.addEventListener('scroll', handleScroll, false);
     56            // move cursor to the right until the text scrolls
     57            while(textarea.scrollLeft === 0){
     58              await moveCursorRightInsideElement(textarea, 1);
     59            }
     60            // if there is no scroll event fired then test will fail by timeout
     61          })},
     62             /*
     63              Moving the cursor using the arrow keys into a textarea element
     64              fires scroll events when text has to scroll into view.
     65              Uses arrow keys to move right in the textarea element.
     66            */
     67              "Scroll event fired for <textarea> element.");
     68      }
     69    </script>
     70 </body>
     71 </html>