chromium/third_party/blink/perf_tests/css/HasDescendantInvalidationMultipleSubjects.html

<!DOCTYPE html>
<html>
<head>
<script src="../resources/runner.js"></script>
<style>
  div { color: grey }
  .a:has(.b) { color: green }
</style>
</head>
<body>
<div id=container class=a></div>
<script>

function addChildren(element, numChildren, idPrefix)
{
  for (var i = 0; i < numChildren; i++) {
    var child = document.createElement("div");
    child.id = idPrefix  + i;
    element.appendChild(child);
  }
}

function makeTree(element, depth, fanOut, idPrefix)
{
  if (depth <= 0)
    return;
  addChildren(element, fanOut, idPrefix);
  for (var child = element.firstChild; child.nextSibling; child = child.nextSibling)
    makeTree(child, depth - 1, fanOut, child.id);
  if (child)
    makeTree(child, depth - 1, fanOut, child.id);
}

makeTree(container, 11, 2, "child");
for (var parent = child11111111111.parentElement;
      parent.id != "container";
      parent = parent.parentElement) {
  parent.classList.add("a");
}
container.offsetHeight; // force recalc style

var runFunction = function()
{
  child0.classList.toggle("b");
  container.offsetHeight; // force recalc style
  child0.classList.toggle("b");
  container.offsetHeight; // force recalc style

  child11111111111.classList.toggle("b");
  container.offsetHeight; // force recalc style
  child11111111111.classList.toggle("b");
  container.offsetHeight; // force recalc style
}

PerfTestRunner.measureRunsPerSecond({
  description: "Measures performance of the '.a:has(.b)' invalidation with multiple subject elements.",
  run: runFunction
});

</script>
</body>
</html>