summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/svg/animations/first-interval-in-the-past-contribute.html
blob: a4c7383b8eefbc439645ffd444cea98584ac1c81 (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
<!DOCTYPE html>
<title>Inserting animation elements that end before current presentation time</title>
<link rel="help" href="https://www.w3.org/TR/2001/REC-smil-animation-20010904/#Timing-BeginEnd-LC-Start">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/rendering-utils.js"></script>
<svg>
  <rect width="100" height="100" fill="orange">
    <animate attributeName="fill" values="blue;red" dur="10ms" fill="freeze"/>
  </rect>
</svg>
<script>
  promise_test(t => {
    const rect = document.querySelector('rect');
    const endWatcher = new Promise(resolve => {
      document.querySelector('animate').onend = resolve;
    });
    return endWatcher
      .then(() => {
        const oldAnimation = rect.firstElementChild;
        const newAnimation = oldAnimation.cloneNode(false);
        newAnimation.setAttribute('values', 'red;green');
        rect.replaceChild(newAnimation, oldAnimation);
        return waitForAtLeastOneFrame();
      })
      .then(() => {
        assert_equals(getComputedStyle(rect).fill, 'rgb(0, 128, 0)', 'new animation applies');
      });
  });
</script>