summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/test_scroll_subframe_scrollbar.html
blob: 10d53e9d045ad3f7f601e2d9db98688ee233f8ee (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE HTML>
<html>
<head>
  <title>Test scrolling subframe scrollbars</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script src="/tests/SimpleTest/EventUtils.js"></script>
  <script src="/tests/SimpleTest/paint_listener.js"></script>
  <script type="application/javascript" src="apz_test_utils.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<style>
p {
  width:200px;
  height:200px;
  border:solid 1px black;
}
</style>
</head>
<body>
<p id="subframe">
1	<br>
2	<br>
3	<br>
4	<br>
5	<br>
6	<br>
7	<br>
8	<br>
9	<br>
10	<br>
11	<br>
12	<br>
13	<br>
14	<br>
15	<br>
16	<br>
17	<br>
18	<br>
19	<br>
20	<br>
21	<br>
22	<br>
23	<br>
24	<br>
25	<br>
26	<br>
27	<br>
28	<br>
29	<br>
30	<br>
31	<br>
32	<br>
33	<br>
34	<br>
35	<br>
36	<br>
37	<br>
38	<br>
39	<br>
40	<br>
</p>
<script clss="testbody" type="text/javascript">

var DefaultEvent = {
  deltaMode: WheelEvent.DOM_DELTA_LINE,
  deltaX: 0, deltaY: 1,
  lineOrPageDeltaX: 0, lineOrPageDeltaY: 1,
};

var ScrollbarWidth = 0;

async function test() {
  var subframe = document.getElementById("subframe");
  var oldClientWidth = subframe.clientWidth;

  subframe.style.overflow = "auto";
  subframe.getBoundingClientRect();

  await promiseAllPaintsDone(null, /*flush=*/true);

  ScrollbarWidth = oldClientWidth - subframe.clientWidth;
  if (!ScrollbarWidth) {
    // Probably we have overlay scrollbars - abort the test.
    ok(true, "overlay scrollbars - skipping test");
    return;
  }

  ok(subframe.scrollHeight > subframe.clientHeight, "subframe should have scrollable content");

  // Send a wheel event roughly to where we think the trackbar is. We pick a
  // point at the bottom, in the middle of the trackbar, where the slider is
  // unlikely to be (since it starts at the top).
  var posX = subframe.clientWidth + (ScrollbarWidth / 2);
  var posY = subframe.clientHeight - 20;

  var oldScrollTop = subframe.scrollTop;

  await new Promise(resolve => {
    sendWheelAndPaint(subframe, posX, posY, DefaultEvent, resolve);
  });

  ok(subframe.scrollTop > oldScrollTop, "subframe should have scrolled");
}

SimpleTest.waitForExplicitFinish();

pushPrefs([["general.smoothScroll", false],
           ["mousewheel.transaction.timeout", 0],
           ["mousewheel.transaction.ignoremovedelay", 0],
           ["test.events.async.enabled", true]])
.then(waitUntilApzStable)
.then(test)
.then(SimpleTest.finish, SimpleTest.finishWithFailure);

</script>
</body>
</html>