summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/presentation-api/controlling-ua/support/presentation.html
blob: ea13ded4ad97b7da0e310ffaedc1bcb87476b993 (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
<!DOCTYPE html>

<meta charset="utf-8">
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="author" title="He Yue" href="mailto:yue.he@intel.com">
<link rel="help" href="http://w3c.github.io/presentation-api/#interface-presentationconnectionlist">
<script>
  var addConnection = function(connection) {
    connection.onconnected = function () {
      this.onmessage = function (evt) {
        this.send(evt.data);
      };
  };
  navigator.receiver.connectionList
    .then(function(list) {
      list.onconnectionavailable = function(connections) {
        addConnection(connections[connections.length - 1]);
      };
      list.connections.map(function(connection) {
        addConnection(connection);
      });
    });
  }
</script>