chromium/tools/perf/page_sets/tough_animation_cases/css_transitions_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/tablet.css">
<link rel="stylesheet" type="text/css" href="resources/transition.css">
<script src="resources/perf_test_helper.js"></script>
<style>
keyframe0 + target {
  opacity: 0;
}
keyframe1 + target {
  opacity: 1;
}
keyframe0, keyframe1 {
  display: none;
}
</style>

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

<script>
var N = PerfTestHelper.getN(1000);
var duration = 1000;
var keyframeValues = [0, 1];
var keyframeStash = [[], []];
var targets = [];

for (var i = 0; i < N; i++) {
  keyframeStash[0].push(document.createElement('keyframe0'));
  keyframeStash[1].push(document.createElement('keyframe1'));
  var target = document.createElement('target');
  target._keyframe = 0;
  target.style.transitionDelay = (-i / N * duration) + 'ms';
  container.appendChild(target);
  target.addEventListener('transitionend', restartTransition);
  targets.push(target);
}

function restartTransition(event) {
  var target = event.target;
  target.style.removeProperty('transition-delay');
  keyframeStash[target._keyframe].push(target.previousSibling);
  target.previousSibling.remove();
  target._keyframe ^= 1;
  container.insertBefore(keyframeStash[target._keyframe].pop(), target);
}

requestAnimationFrame(function() {
  requestAnimationFrame(function(){
    targets.forEach(function(target) {
      container.insertBefore(keyframeStash[0].pop(), target);
    });
  });
});

PerfTestHelper.signalReady();
</script>