summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/presentation-api/receiving-ua/support/iframe.html
blob: 61f18b8912d352bdb58d8205d2b2becde4f76a4e (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>
<meta charset="utf-8">
<title>Helper functions invoked by a nested browsing context</title>
<link rel="author" title="Tomoyuki Shimizu" href="https://github.com/tomoyukilabs">
<link rel="help" href="https://w3c.github.io/presentation-api/#monitoring-incoming-presentation-connections">

<script>
  window.addEventListener('message', event => {
    const data = event.data;

    if (!data.type)
      return;
    else if (data.type === 'connect') {
      const request = new PresentationRequest(data.url);
      request.reconnect(data.id).then(c => {
        c.onterminate = () => {
          window.parent.postMessage({ type: 'terminated' }, '*');
        };
      });
    }
  });
</script>