summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_bug1550510.html
blob: 2f3be5dd2c12a363f3f36dfac618cb0e6bbe82c6 (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
59
60
61
62
63
64
65
66
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width; initial-scale=1.0">
  <title>Dragging the mouse on a scrollbar for a transformed, filtered scrollframe</title>
  <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
  <script type="application/javascript" src="apz_test_utils.js"></script>
  <script src="/tests/SimpleTest/paint_listener.js"></script>
  <script type="text/javascript">

async function test() {
  var scrollableDiv = document.getElementById("scrollable");
  let scrollPromise = new Promise(resolve => {
    scrollableDiv.addEventListener("scroll", resolve, {once: true});
  });

  // Scroll down a small amount (10px). The bug in this case is that the
  // scrollthumb "jumps" most of the way down the scroll track because with
  // WR enabled the filter and transform display items combine to generate an
  // incorrect APZC tree, and the mouse position gets untransformed incorrectly.
  // Given the scrollable height of 2000px and scrollframe height of 400px,
  // the scrollthumb should be approximately 80px tall, and dragging it 10px
  // should scroll approximately 50 pixels. If the bug manifests, it will get
  // dragged an extra ~150px and scroll to approximately 1250px.
  var dragFinisher = await promiseVerticalScrollbarDrag(scrollableDiv, 10, 10);
  if (!dragFinisher) {
    ok(true, "No scrollbar, can't do this test");
    return;
  }

  // the events above might be stuck in APZ input queue for a bit until the
  // layer is activated, so we wait here until the scroll event listener is
  // triggered.
  await scrollPromise;

  await dragFinisher();

  // Flush everything just to be safe
  await promiseOnlyApzControllerFlushed();

  // In this case we just want to make sure the scroll position moved from 0
  // which indicates the thumb dragging worked properly.
  ok(scrollableDiv.scrollTop < 100, "Scrollbar drag resulted in a scroll position of " + scrollableDiv.scrollTop);
}

waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);

  </script>
</head>
<body>
    <div style="position: fixed; left: 100px; top: 100px; width: 400px; height: 600px">
        <div style="transform: translateY(150px); will-change: transform">
            <div style="filter: grayscale(80%)">
                <div id="scrollable" style="height: 400px; overflow-y: auto">
                    <div style="min-height: 2000px">
                        yay text
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>