summaryrefslogtreecommitdiffstats
path: root/layout/reftests/css-animations/scroll-timeline-in-delay-omta.html
blob: 4dea5b7854760eefbe4f03364d6d5aacb1cf4909 (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
<!DOCTYPE html>
<html class="reftest-wait reftest-no-flush">
<head>
<title>Scroll the scroll-driven animation from the active phase to delay</title>
<style>
  @keyframes anim {
    from { translate: 100px; }
    to { translate: 200px; }
  }
  #scroller {
    width: 100px;
    height: 100px;
    overflow: scroll;
    scrollbar-width: none;
    scroll-timeline: scroll_timeline;
  }
  #target {
    width: 100px;
    height: 100px;
    background: green;
    rotate: 45deg;
    translate: 50px;
    animation-name: anim;
    animation-duration: 5s;
    animation-timing-function: linear;
    animation-delay: 5s;
    animation-timeline: scroll_timeline;
  }
</style>
<script>
window.addEventListener("MozReftestInvalidate", async () => {
  const scroller = document.getElementById("scroller");
  scroller.scrollTop = 75;

  // Wait for the MozAfterPaint to make the view id of |scroller| gets ready.
  window.addEventListener('MozAfterPaint', async () => {
    let utils = SpecialPowers.wrap(window).windowUtils;
    utils.setAsyncScrollOffset(scroller, 0, -50);

    await new Promise(function(resolve, reject) {
      let repaintDone = function() {
        SpecialPowers.Services.obs.removeObserver(
          repaintDone,
          "apz-repaints-flushed"
        );
        resolve();
      };
      SpecialPowers.Services.obs.addObserver(repaintDone,
                                             "apz-repaints-flushed");
      if (!utils.flushApzRepaints()) {
        repaintDone();
      }
    });

    // Wait for composition and then take the snapshot.
    await new Promise(resolve => { requestAnimationFrame(resolve); });
    await new Promise(resolve => { requestAnimationFrame(resolve); });

    document.documentElement.classList.remove('reftest-wait');
  }, {once: true});
});

</script>
</head>
<body>
  <div id="scroller">
    <div style="height: 100px; padding-bottom: 100px;"></div>
  </div>
  <div id="target"></div>
</body>
</html>