summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/svg/animations/syncbase-remove-add-while-running.html
blob: 61b9604a7b6751a156c48431b89fa2f3cd1af551 (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>
<meta charset="utf-8">
<title>Remove/Add syncbase while animation is running</title>
<link rel="help" href="https://www.w3.org/TR/SMIL3/smil-timing.html#q26">
<link rel="author" title="Edvard Thörnros" href="mailto:edvardt@opera.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<svg>
  <animate id="anim" attributeName="visibility" to="visible" begin="10s" dur="2s"/>
  <rect x="0" y="0" width="0" height="100" fill="#0F0">
    <set attributeName="width" fill="freeze" to="100" begin="anim.begin"/>
  </rect>
</svg>

<script>
  async_test(function(t) {
    window.onload = t.step_func(function() {
      let svg = document.querySelector("svg");
      let rect = document.querySelector("rect");

      window.requestAnimationFrame(t.step_func(function() {
        window.requestAnimationFrame(t.step_func(function() {
          var anim1 = document.getElementById("anim");
          anim1.parentNode.removeChild(anim1);

          var anim2 = document.createElementNS("http://www.w3.org/2000/svg", "animate");
          anim2.setAttribute("id", "anim");
          anim2.setAttribute("attributeName", "visibility");
          anim2.setAttribute("to", "visible");
          anim2.setAttribute("begin", "0s");
          anim2.setAttribute("dur", "2s");
          svg.appendChild(anim2);

          window.requestAnimationFrame(t.step_func(function() {
            window.requestAnimationFrame(t.step_func_done(function() {
              svg.pauseAnimations();
              assert_equals(rect.width.animVal.value, 100, "Sync base triggered");
            }));
          }));
        }));
      }));
    });
  });
</script>