summaryrefslogtreecommitdiffstats
path: root/dom/media/tests/mochitest/identity/test_setIdentityProvider.html
blob: ee65d5af59071f96594fe6273b06b7432b08c149 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE HTML>
<html>
<head>
  <script type="application/javascript">var scriptRelativePath = "../";</script>
  <script type="application/javascript" src="../pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
  createHTML({
    title: "setIdentityProvider leads to peerIdentity and assertions in SDP",
    bug: "942367"
  });

function checkIdentity(peer, prefix, idp, name) {
  prefix = prefix + ": ";
  return peer._pc.peerIdentity.then(peerIdentity => {
    ok(peerIdentity, prefix + "peerIdentity is set");
    is(peerIdentity.idp, idp, prefix + "IdP is correct");
    is(peerIdentity.name, name + "@" + idp, prefix + "identity is correct");
  });
}

function theTest() {
  var test = new PeerConnectionTest();
  test.setMediaConstraints([{audio: true}], [{audio: true}]);
  test.pcLocal.setIdentityProvider("test1.example.com", "idp.js", "someone");
  test.pcRemote.setIdentityProvider("test2.example.com", "idp.js", "someone");

  test.chain.append([
    function PC_LOCAL_PEER_IDENTITY_IS_SET_CORRECTLY(test) {
      return checkIdentity(test.pcLocal, "local", "test2.example.com", "someone");
    },
    function PC_REMOTE_PEER_IDENTITY_IS_SET_CORRECTLY(test) {
      return checkIdentity(test.pcRemote, "remote", "test1.example.com", "someone");
    },

    function OFFER_AND_ANSWER_INCLUDES_IDENTITY(test) {
      ok(test.originalOffer.sdp.includes("a=identity"), "a=identity is in the offer SDP");
      ok(test.originalAnswer.sdp.includes("a=identity"), "a=identity is in the answer SDP");
    },

    function PC_LOCAL_DESCRIPTIONS_CONTAIN_IDENTITY(test) {
      ok(test.pcLocal.localDescription.sdp.includes("a=identity"),
         "a=identity is in the local copy of the offer");
      ok(test.pcLocal.remoteDescription.sdp.includes("a=identity"),
         "a=identity is in the local copy of the answer");
    },
    function PC_REMOTE_DESCRIPTIONS_CONTAIN_IDENTITY(test) {
      ok(test.pcRemote.localDescription.sdp.includes("a=identity"),
                         "a=identity is in the remote copy of the offer");
      ok(test.pcRemote.remoteDescription.sdp.includes("a=identity"),
                         "a=identity is in the remote copy of the answer");
    }
  ]);
  test.run();
}
runNetworkTest(theTest);

</script>
</pre>
</body>
</html>