Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'linux' && os_version == '22.04' && display == 'wayland'
- Manifest: gfx/layers/apz/test/mochitest/mochitest.toml
<!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>