11cb0ef41Sopenharmony_ci<!doctype html>
21cb0ef41Sopenharmony_ci<html>
31cb0ef41Sopenharmony_ci<head>
41cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script>
51cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script>
61cb0ef41Sopenharmony_ci<script src="/resources/testdriver.js"></script>
71cb0ef41Sopenharmony_ci<script src="/resources/testdriver-actions.js"></script>
81cb0ef41Sopenharmony_ci<script src="/resources/testdriver-vendor.js"></script>
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci</head>
111cb0ef41Sopenharmony_ci<body onload=runTest()>
121cb0ef41Sopenharmony_ci    <p>Moving the cursor using the arrow keys into an
131cb0ef41Sopenharmony_ci        input element fires scroll events when text has to scroll into view.
141cb0ef41Sopenharmony_ci        Uses arrow keys to move forward and backwards in the input
151cb0ef41Sopenharmony_ci        element.</p>
161cb0ef41Sopenharmony_ci    <input type="text" style='width: 50px'
171cb0ef41Sopenharmony_ci    value="Fooooooooooooooooooooooooooooooooooooooooooooooooo"/>
181cb0ef41Sopenharmony_ci    <textarea rows="4" cols="4">
191cb0ef41Sopenharmony_ci        Fooooooooooooooooooooooooooooooooooooooooooooooooo
201cb0ef41Sopenharmony_ci    </textarea>
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci    <script>
231cb0ef41Sopenharmony_ci      async function moveCursorRightInsideElement(element, value){
241cb0ef41Sopenharmony_ci          var arrowRight = '\uE014';
251cb0ef41Sopenharmony_ci          for(var i=0;i<value;i++){
261cb0ef41Sopenharmony_ci            await test_driver.send_keys(element, arrowRight);
271cb0ef41Sopenharmony_ci          }
281cb0ef41Sopenharmony_ci      }
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci      function runTest(){
311cb0ef41Sopenharmony_ci          promise_test(async(t) => { return new Promise(async (resolve, reject) => {
321cb0ef41Sopenharmony_ci            var input = document.getElementsByTagName('input')[0];
331cb0ef41Sopenharmony_ci            function handleScroll(){
341cb0ef41Sopenharmony_ci              resolve("Scroll Event successfully fired!");
351cb0ef41Sopenharmony_ci            }
361cb0ef41Sopenharmony_ci            input.addEventListener('scroll', handleScroll, false);
371cb0ef41Sopenharmony_ci            // move cursor to the right until the text scrolls
381cb0ef41Sopenharmony_ci            while(input.scrollLeft === 0){
391cb0ef41Sopenharmony_ci              await moveCursorRightInsideElement(input, 1);
401cb0ef41Sopenharmony_ci            }
411cb0ef41Sopenharmony_ci            // if there is no scroll event fired then test will fail by timeout
421cb0ef41Sopenharmony_ci          })},
431cb0ef41Sopenharmony_ci             /*
441cb0ef41Sopenharmony_ci               Moving the cursor using the arrow keys into an input element
451cb0ef41Sopenharmony_ci               fires scroll events when text has to scroll into view.
461cb0ef41Sopenharmony_ci               Uses arrow keys to move right in the input element.
471cb0ef41Sopenharmony_ci             */
481cb0ef41Sopenharmony_ci           "Scroll event fired for <input> element.");
491cb0ef41Sopenharmony_ci
501cb0ef41Sopenharmony_ci          promise_test(async(t) => { return new Promise(async (resolve, reject) => {
511cb0ef41Sopenharmony_ci            var textarea = document.getElementsByTagName('textarea')[0];
521cb0ef41Sopenharmony_ci            function handleScroll(){
531cb0ef41Sopenharmony_ci              resolve("Scroll Event successfully fired!");
541cb0ef41Sopenharmony_ci            }
551cb0ef41Sopenharmony_ci            textarea.addEventListener('scroll', handleScroll, false);
561cb0ef41Sopenharmony_ci            // move cursor to the right until the text scrolls
571cb0ef41Sopenharmony_ci            while(textarea.scrollLeft === 0){
581cb0ef41Sopenharmony_ci              await moveCursorRightInsideElement(textarea, 1);
591cb0ef41Sopenharmony_ci            }
601cb0ef41Sopenharmony_ci            // if there is no scroll event fired then test will fail by timeout
611cb0ef41Sopenharmony_ci          })},
621cb0ef41Sopenharmony_ci             /*
631cb0ef41Sopenharmony_ci              Moving the cursor using the arrow keys into a textarea element
641cb0ef41Sopenharmony_ci              fires scroll events when text has to scroll into view.
651cb0ef41Sopenharmony_ci              Uses arrow keys to move right in the textarea element.
661cb0ef41Sopenharmony_ci            */
671cb0ef41Sopenharmony_ci              "Scroll event fired for <textarea> element.");
681cb0ef41Sopenharmony_ci      }
691cb0ef41Sopenharmony_ci    </script>
701cb0ef41Sopenharmony_ci</body>
711cb0ef41Sopenharmony_ci</html>
72