summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/scroll-behavior/main-frame-scrollTop.html
blob: 98bd121e6dde13e10d0d4c1b275b9b68d0427fc4 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<html>
<head>
  <style>
    #content {
      width: 7500px;
      height: 7500px;
      background-color: blue;
    }
  </style>
  <script src="../../resources/testharness.js"></script>
  <script src="../../resources/testharnessreport.js"></script>
  <script src="resources/scroll-behavior-test.js"></script>
  <script type="text/javascript">
    function getEndPosition(testCase, startPosition) {
      var endPosition = {};
      endPosition.x = startPosition.x;
      endPosition.y = testCase.y;
      return endPosition;
    }

    function jsScroll(testCase) {
      document.scrollingElement.scrollTop = testCase.y;
    }

    const testScrolls = [
      {css: "auto", x: 0, y: 2},
      {css: "auto", x: 0, y: 4},
      {css: "smooth", waitForEnd: true, x: 0, y: 25},
      {css: "smooth", waitForEnd: true, x: 0, y: 45},
      {css: "smooth", waitForEnd: false, x: 0, y: 4100},
      {css: "smooth", waitForEnd: false, x: 0, y: 20},
    ];

    function doTest()
    {
      var testCases = [];
      for (var i = 0; i < testScrolls.length; i++) {
        testCases.push(new ScrollBehaviorTestCase(testScrolls[i]));
      }

      var scrollBehaviorTest = new ScrollBehaviorTest(document.scrollingElement,
                                                      document,
                                                      testCases,
                                                      getEndPosition,
                                                      jsScroll);
      scrollBehaviorTest.run();
    }

    window.addEventListener('load', doTest, false);
  </script>
</head>

<body>
  <p>Test that setting scrollTop on the main frame works with both scroll behaviors</p>
  <div id="content"></div>
</body>
</html>