summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_smoothscroll_spam_interleaved.html
blob: 003ae49ea5373b1a81bdc2cf4872d9dd8d9b88ce (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
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width; initial-scale=1.0">
  <title>Test for scenario in bug 1228407 with two scrollframes</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="application/javascript">

async function test() {
  let utils = SpecialPowers.getDOMWindowUtils(window);
  utils.advanceTimeAndRefresh(0);

  // Basically the same setup as in helper_smoothscroll_spam.html, but
  // with two scrollframes that get scrolled in an interleaved manner.
  // The original fix for bug 1228407 left this scenario unhandled, with
  // bug 1231177 tracking the problem. This test exercises the scenario.
  let s1 = document.getElementById('s1');
  let s2 = document.getElementById('s2');
  for (let i = 0; i < 100; i++) {
    s1.scrollBy({top:60, behavior: "smooth"});
    s2.scrollBy({top:60, behavior: "smooth"});
    await promiseOnlyApzControllerFlushed();
    utils.advanceTimeAndRefresh(16);
  }

  utils.restoreNormalRefresh();
  await promiseOnlyApzControllerFlushed();

  let s1pos = s1.scrollTop;
  let s2pos = s2.scrollTop;
  ok(s1pos > 60, `s1 scrolled ${s1pos}px, should be more than 60`);
  ok(s2pos > 60, `s2 scrolled ${s2pos}px, should be more than 60`);
}

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

  </script>
  <style>
    .scrollable {
      overflow: scroll;
      height: 300px;
    }

    .content {
      height: 1000px;
      background-image: linear-gradient(green, blue);
    }
  </style>
</head>
<body>
 <div id="s1" class="scrollable"><div class="content"></div></div>
 <div id="s2" class="scrollable"><div class="content"></div></div>
</body>
</html>