<!DOCTYPE html>
<body>
  <script>
    async function handleMessage(e) {
      if (e.data == "focus" || e.data == "focus-update-active-element") {
        let iframe = document.querySelector("iframe");
        iframe.contentWindow.postMessage(e.data, "*");
      }
    }

    if (window.portalHost)
      window.portalHost.onmessage = handleMessage;

    window.onportalactivate = e => {
      var portal = e.adoptPredecessor();
      document.body.appendChild(portal);
      portal.onmessage = handleMessage;
    }

    window.onmessage = e => {
      if (window.portalHost)
        window.portalHost.postMessage(e.data);
      else
        document.querySelector("portal").postMessage(e.data);
    }
  </script>
  <iframe src="http://{{hosts[alt][www]}}:{{ports[http][0]}}/portals/resources/focus-page-with-button.html"></iframe>
</body>
