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

<!DOCTYPE html>
<html>
<head>
<script src="../resources/runner.js"></script>
<style>
  div { color: grey }
  .a:has(.b) .c { 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");
}
child11111111110.classList.toggle("c");
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) .c' invalidation with multiple :has() anchor elements",
  run: runFunction
});

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