summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/nodes/moveBefore/tentative/continue-css-animation-transform.html
blob: e7a285893aa0e4a538ec29af944f1d0761d93f0a (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
<!DOCTYPE html>
<title>Node.moveBefore should preserve CSS animation state (transform)</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<body>
  <section id="old-parent">
    <div id="item"></div>
  </section>
  <section id="new-parent">
  </section>
  <style>
    @keyframes anim {
      from {
        transform: translateX(100px);
      }

      to {
        transform: translateX(400px);
      }
    }

    #item {
      position: relative;
      width: 100px;
      height: 100px;
      background: green;
      animation: 1s linear infinite alternate anim;
      animation-delay: 100ms;
    }
  </style>
  <script>
    promise_test(async t => {
      const item = document.querySelector("#item");
      let num_events = 0;
      await new Promise(resolve => addEventListener("animationstart", () => {
        num_events++;
        resolve();
      }));

      // Reparent item
      document.body.querySelector("#new-parent").moveBefore(item, null);
      await new Promise(resolve => requestAnimationFrame(() => resolve()));
      assert_equals(num_events, 1);
      assert_not_equals(getComputedStyle(item).transform, "none");
    });
  </script>
</body>