chromium/tools/perf/page_sets/tough_animation_cases/css_animations_staggered_chaining_by_inserting_new_element.html

<!DOCTYPE html>
<meta name="viewport" content="width=device-width, user-scalable=no">
<link rel="stylesheet" type="text/css" href="resources/animation.css">
<link rel="stylesheet" type="text/css" href="resources/tablet.css">
<script src="resources/perf_test_helper.js"></script>

<container id="container"></container>

<script>
var N = PerfTestHelper.getN(1000);
var duration = 1000;

function startAnimation() {
  var target = document.createElement('target');
  target.i = 1;
  container.appendChild(target);
  target.addEventListener('webkitAnimationEnd', function(e) {
    e.target.remove();
    startAnimation();
  });
}

requestAnimationFrame(function(t) {
  var base = t;
  var i = 0;

  function staggeredStart(t) {
    elapsed = t - base;
    for (; i < N * elapsed / duration; i++) {
      startAnimation();
    }
    if (i < N) {
      requestAnimationFrame(staggeredStart);
    } else {
      PerfTestHelper.signalReady();
    }
  }
  requestAnimationFrame(staggeredStart);
});
</script>