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

    var waitForPortalToLoad = portal => new Promise((resolve, reject) => {
      portal.onload = resolve;
    });

    Promise.all([waitForPortalToLoad(portal1),
                 waitForPortalToLoad(portal2)]).then(() => {
      portal1.activate();
      portal2.activate().catch(e => window.opener.postMessage(e.name, "*"));
    });

    document.body.append(portal1);
    document.body.append(portal2);
  </script>
</body>