summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/events/scrolling/scrollend-fires-to-text-input.html
blob: edc75d9121776e1be660112e1257402ddd1ab5d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!DOCTYPE html>
<html>
  <head>
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
  </head>
  <body>
    <style>
      #inputscroller {
        width: 100px;
        height: 50px;
      }
    </style>
    <input type="text" id="inputscroller"
    value="qwertyuiopasddfghjklzxcvbnmqwertyuiopasddfghjklzxcvbnmqwer">
    <script>
      promise_test(async() => {
        const inputscroller = document.getElementById("inputscroller");
        assert_equals(inputscroller.scrollLeft, 0,
          "text input field is not initially scrolled.");

        const scrollend_promise = new Promise((resolve) => {
          inputscroller.addEventListener("scrollend", resolve);
        });
        inputscroller.scrollLeft = 10;
        await scrollend_promise;
        assert_equals(inputscroller.scrollLeft, 10,
          "text input field is scrolled by the correct amount");
      }, "scrolled input field should receive scrollend.");
    </script>
  </body>
</html>