<!DOCTYPE html>
<script>
function test() {
  document.body.offsetHeight;
  document.body.attachShadow({mode: 'closed'});
  iframe.contentDocument.caretRangeFromPoint(0, 0);
}
</script>
<iframe id="iframe" onload="test()"></iframe>
