summaryrefslogtreecommitdiffstats
path: root/dom/animation/test/mozilla/file_disable_animations_api_autoremove.html
blob: 79cb50846722c616ffc9d462977337fcddd0702a (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
<!doctype html>
<meta charset=utf-8>
<script src="../testcommon.js"></script>
<body>
<script>
'use strict';

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

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

  // This should be assert_not_own_property but our local copy of testharness.js
  // is old.
  assert_equals(
    animA.replaceState,
    undefined,
    'Should not have a replaceState member'
  );

  animA.addEventListener(
    'remove',
    t.step_func(() => {
      assert_unreached('Should not fire a remove event');
    })
  );

  // Allow a chance for the remove event to be fired

  await animA.finished;
  await waitForNextFrame();
}, 'Remove events should not be fired if the pref is not set');

promise_test(async t => {
  const div = addDiv(t);
  div.style.opacity = '0.1';

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

  await animA.finished;

  assert_approx_equals(
    parseFloat(getComputedStyle(div).opacity),
    0.5,
    0.0001,
    'Covered animation should still contribute to effect stack when adding'
  );

  animB.cancel();

  assert_approx_equals(
    parseFloat(getComputedStyle(div).opacity),
    0.2,
    0.0001,
    'Covered animation should still contribute to animated style when replacing'
  );
}, 'Covered animations should still affect style if the pref is not set');

done();
</script>
</body>