summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/portals/resources/portal-activate-event-portal.html
blob: 6de5aafca78a261f879dd1f88f3eb124b91a621d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!DOCTYPE html>
<title>Tests that the PortalActivateEvent is dispatched when a portal is activated</title>
<script>
  var test = (new URL(location)).searchParams.get("test");

  function portalActivate(e) {
    var bc = new BroadcastChannel("test-" + test);
    bc.postMessage("passed");
    bc.close();
  }

  if (test == "bodyeventhandler") {
    document.write('<body onportalactivate="portalActivate()"></body>');
  } else if (test == "eventhandler") {
    window.onportalactivate = portalActivate;
  } else if (test == "eventlistener") {
    window.addEventListener("portalactivate", portalActivate);
  }

  window.portalHost.postMessage("loaded");
</script>