summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/portals/resources/portal-post-message-after-activate-window.html
blob: 73d2c115587ceca5b1583ce909ad4184cebfd0c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!DOCTYPE html>
<body>
  <script>
    var portal = document.createElement("portal");
    portal.src = "portal-post-message-portal.html";
    document.body.appendChild(portal);

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