summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_bug1783936.html
blob: 8aec5eafef37a7f9f49998d87a546ef6296452c0 (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
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Test that scroll snap happens on pan end without fling</title>
  <script src="apz_test_utils.js"></script>
  <script src="apz_test_native_event_utils.js"></script>
  <script src="/tests/SimpleTest/paint_listener.js"></script>
  <style>
    body {
      margin: 0;
      padding: 0;
    }
    html {
      overflow-y: scroll;
      scroll-snap-type: y mandatory;
      scroll-behavior: auto;
    }
    .snap {
      width: 100%;
      height: 100vh;
      background-color: blue;
      position: absolute;
      top: 200px;
      scroll-snap-align: start;
    }
  </style>
</head>
<body>
  <div class="snap"></div>
  <div style="width: 100%; height: 500vh;"></div>
  <script type="application/javascript">
    async function test() {
      is(window.scrollY, 200, "The initial layout should result snapping to 200px");

      // Start scrolling back by a pan gesture and wait its' scroll end.
      let transformEndPromise = promiseTransformEnd();
      await promiseNativeTouchpadPanEventAndWaitForObserver(
        window,
        100,
        100,
        0, -100,
        SpecialPowers.DOMWindowUtils.PHASE_BEGIN);

      // Finish the pan gesture.
      await promiseNativeTouchpadPanEventAndWaitForObserver(
        window,
        100,
        100,
        0, 0,
        SpecialPowers.DOMWindowUtils.PHASE_END);
      await transformEndPromise;

      // Make sure the new scroll positions have reached to the main-thread.
      await promiseOnlyApzControllerFlushed();

      is(window.scrollY, 200, "The pan-end should result snapping to 200px");
    }

    // This test is supposed to run on environments where
    // PanGestureInput.mSimulateMomentum for pan gestures is true, which means
    // as of now it's only on Linux.
    if (getPlatform() == "linux") {
      waitUntilApzStable()
      .then(test)
      .then(subtestDone, subtestFailed);
    } else {
      ok(true, "Skipping test because this test isn't supposed to work on " + getPlatform());
      subtestDone();
    }
  </script>
</body>
</html>