summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-backgrounds/animations/background-color-animation-will-change-contents.html
blob: a218098721c175064fcb988f31da2ed92fda67bc (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
<!DOCTYPE html>
<html class="reftest-wait">
<link rel="help" href="https://drafts.csswg.org/css-backgrounds-3/#background-color">
<link rel="match" href="background-color-animation-will-change-contents-ref.html">
<style>
.container {
  width: 600px;
  height: 600px;
  will-change: contents;
  /* Start with a short delay and ensure that we pick up the color change when
     the animation enters the active phase. */
  animation: bgcolor 10s steps(1, jump-start) backwards 0.2s;
}
@keyframes bgcolor {
  0% { background-color: rgba(200, 0, 0, 1); }
  100% { background-color: rgba(0, 200, 0, 1); }
}
</style>
<script src="/common/reftest-wait.js"></script>
<body>
<div class="container"></div>

<script>
  function waitForActiveAnimation() {
    const anim = document.getAnimations()[0];
    return new Promise(resolve => {
      const tick = () => {
        requestAnimationFrame(() => {
          if (anim.currentTime > 200)
            resolve();
          else
            tick();
        });
      };
      tick();
    });
  }

  window.onload = async () => {
    await waitForActiveAnimation();
    takeScreenshot();
  };
</script>
</body>
</html>