summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/web-animations/interfaces/Animation/persist.html
blob: c18993cbc44427af1b3ceeeedb4dcbac42d7957c (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
<!doctype html>
<meta charset=utf-8>
<title>Animation.persist</title>
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animation-persist">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
<body>
<div id="log"></div>
<script>
'use strict';

async_test(t => {
  const div = createDiv(t);

  const animA = div.animate({ opacity: 1 }, { duration: 1, fill: 'forwards' });
  const animB = div.animate({ opacity: 1 }, { duration: 1, fill: 'forwards' });

  animA.onremove = t.step_func_done(() => {
    assert_equals(animA.replaceState, 'removed');
    animA.persist();
    assert_equals(animA.replaceState, 'persisted');
  });
}, 'Allows an animation to be persisted after being removed');

promise_test(async t => {
  const div = createDiv(t);

  const animA = div.animate({ opacity: 1 }, { duration: 1, fill: 'forwards' });
  const animB = div.animate({ opacity: 1 }, { duration: 1, fill: 'forwards' });

  animA.persist();

  await animA.finished;

  assert_equals(animA.replaceState, 'persisted');
}, 'Allows an animation to be persisted before being removed');

</script>
</body>