chromium/third_party/blink/web_tests/scrollbars/custom-scrollbar-reconstruction-document-write.html

<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<iframe></iframe>
<script>

function writeDoc() {
  var doc = document.querySelector("iframe").contentDocument;
  doc.open();
  doc.write(`
    <style>
      ::-webkit-scrollbar-thumb { background-color: blue; }
      ::-webkit-scrollbar { width: 50px; height: 50px; }
      body { height: 400px; overflow: scroll; }
    </style>`);
  doc.close();
  assert_equals(doc.documentElement.offsetWidth, 250);
}

test(() => {
  writeDoc();
  writeDoc();
}, "Preserve iframe custom scrollbar after replacing contents with document.write.");

</script>