<!DOCTYPE html>
<body>
  <script>
    var portal = document.createElement("portal");
    portal.src = "simple-portal.html";
    document.body.appendChild(portal);

    portal.onload = () => {
      portal.activate();
      error = "";
      try {
        portal.postMessage("message");
      } catch (err) {
        error = err.name;
      }
      bc = new BroadcastChannel("portals-post-message-during-activate");
      bc.postMessage(error);
      bc.close();
    }
  </script>
</body>
