summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/capability-delegation/resources/delegate-fullscreen-request-recipient.html
blob: 11daf738d6856d72b6a575639915443659785df3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!DOCTYPE html>
<title>Capability Delegation of Fullscreen Requests test recipient</title>
<body>Capability Delegation of Fullscreen Requests test recipient body</body>

<script>
  const initiator = window.opener ? window.opener : window.top;
  initiator.postMessage({"type": "recipient-loaded"}, "*");

  function reportResult(msg) {
      initiator.postMessage({"type": "result", "result": msg}, "*");
  }

  document.addEventListener('fullscreenchange', async () => {
      if (document.fullscreenElement) {
          await document.exitFullscreen();
          reportResult("success");
      }
  });

  document.addEventListener('fullscreenerror', () => {
      reportResult("failure");
  });

  window.addEventListener("message", e => {
      if (e.data.type == "make-fullscreen-request") {
          document.body.requestFullscreen();
      }
  });
</script>