<!DOCTYPE html>
<div>This frame should not be focused!</div>
<script>
  let got_focus = false;
  window.addEventListener("focus", () => {
    got_focus = true;
  });

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

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