chromium/third_party/blink/web_tests/external/wpt/scroll-to-text-fragment/resources/self-text-directive-iframe.html

<!doctype html>
<!-- This document navigates itself to a text directive and messages the top window with
     the resulting scroll position -->
<style>
  p {
    margin-top: 2000px;
  }
</style>

<script>
  window.onscroll = () => {
    window.top.postMessage("did_scroll", "*");
  };
  window.onload = () => {
    window.location.hash = ':~:text=Target';
  };
</script>

<p>
  Target
</p>