summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnection_terminate_receiving-ua.html
blob: 3a234aaa8339b0e1a3d070be306708d83561dd0b (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>

<meta charset="utf-8">
<title>Terminating a presentation in a receiving browsing context</title>
<link rel="author" title="Tomoyuki Shimizu" href="https://github.com/tomoyukilabs/">
<link rel="help" href="https://w3c.github.io/presentation-api/#terminating-a-presentation-in-a-receiving-browsing-context">
<script src="../common.js"></script>
<script src="stash.js"></script>

<script>
  const stash = new Stash(stashIds.toReceiver, stashIds.toController);

  navigator.presentation.receiver.connectionList.then(list => {
    const connection = list.connections[0];

    // terminate a presentation when two presentation connections become "connected"
    list.onconnectionavailable = evt => {
      connection.terminate();

      stash.sendBeacon({ type: (window.closed ? 'ok' : 'error') });
    };
  });
</script>