<!DOCTYPE html>
<input id="target" value="This should be unfocused!" autofocus></input>

<script>
  let got_focus = false;
  document.getElementById("target").addEventListener("focus", () => {
    got_focus = true;
  });

  window.addEventListener("load", () => {
    parent.postMessage("child_loaded", "*");
  });

  window.addEventListener("message", event => {
    if (event.data == "report_focus_state") {
      let msg = got_focus ? "child_is_focused" : "child_is_not_focused";
      parent.postMessage(msg, "*");
    }
  });
</script>
