1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/media/tests/identity/test_setIdentityProvider.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,115 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <meta charset="utf-8"/> 1.8 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.9 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.10 + <script type="application/javascript" src="../mochitest/head.js"></script> 1.11 + <script type="application/javascript" src="../mochitest/pc.js"></script> 1.12 + <script type="application/javascript" src="../mochitest/templates.js"></script> 1.13 + <script type="application/javascript" src="identityevent.js"></script> 1.14 +</head> 1.15 +<body> 1.16 +<pre id="test"> 1.17 +<script type="application/javascript"> 1.18 + createHTML({ 1.19 + title: "setIdentityProvider leads to peerIdentity and assertions in SDP" 1.20 + }); 1.21 + 1.22 +var test; 1.23 +function theTest() { 1.24 + test = new PeerConnectionTest(); 1.25 + test.setMediaConstraints([{audio: true}], [{audio: true}]); 1.26 + test.setIdentityProvider(test.pcLocal, "test1.example.com", "idp.html", "someone"); 1.27 + test.setIdentityProvider(test.pcRemote, "test2.example.com", "idp.html", "someone"); 1.28 + 1.29 + var localEvents = trapIdentityEvents(test.pcLocal._pc); 1.30 + var remoteEvents = trapIdentityEvents(test.pcRemote._pc); 1.31 + 1.32 + test.chain.append([ 1.33 + [ 1.34 + "PEER_IDENTITY_IS_SET_CORRECTLY", 1.35 + function(test) { 1.36 + var outstanding = 0; 1.37 + // we have to wait for the identity result in order to get the actual 1.38 + // identity information, since the call will complete before the identity 1.39 + // provider has a chance to finish verifying... that's OK, but it makes 1.40 + // testing more difficult 1.41 + 1.42 + function checkOrSetupCheck(pc, pfx, idp, name) { 1.43 + function checkIdentity() { 1.44 + ok(pc.peerIdentity, pfx + "peerIdentity is set"); 1.45 + is(pc.peerIdentity.idp, idp, pfx + "IdP is correct"); 1.46 + is(pc.peerIdentity.name, name + "@" + idp, pfx + "identity is correct"); 1.47 + } 1.48 + if (pc.peerIdentity) { 1.49 + info(pfx + "peerIdentity already set"); 1.50 + checkIdentity(); 1.51 + } else { 1.52 + ++outstanding; 1.53 + info(pfx + "setting onpeeridentity handler"); 1.54 + pc.onpeeridentity = function checkIdentityEvent(e) { 1.55 + info(pfx + "checking peerIdentity"); 1.56 + checkIdentity(); 1.57 + --outstanding; 1.58 + if (outstanding <= 0) { 1.59 + test.next(); 1.60 + } 1.61 + }; 1.62 + } 1.63 + } 1.64 + 1.65 + checkOrSetupCheck(test.pcLocal._pc, "local: ", "test2.example.com", "someone"); 1.66 + checkOrSetupCheck(test.pcRemote._pc, "remote: ", "test1.example.com", "someone"); 1.67 + if (outstanding <= 0) { 1.68 + test.next(); 1.69 + } 1.70 + } 1.71 + ], 1.72 + [ 1.73 + "CHECK_IDENTITY_EVENTS", 1.74 + function(test) { 1.75 + ok(!localEvents.idpassertionerror , "No assertion generation errors on local"); 1.76 + ok(!remoteEvents.idpassertionerror, "No assertion generation errors on remote"); 1.77 + ok(!localEvents.idpvalidationerror, "No assertion validation errors on local"); 1.78 + ok( !remoteEvents.idpvalidationerror, "No assertion validation errors on remote"); 1.79 + ok(localEvents.identityresult, "local acquired identity assertions"); 1.80 + ok(remoteEvents.identityresult, "remote acquired identity assertions"); 1.81 + ok(localEvents.peeridentity, "local got peer identity"); 1.82 + ok(remoteEvents.peeridentity, "remote got peer identity"); 1.83 + test.next(); 1.84 + } 1.85 + ], 1.86 + [ 1.87 + "OFFERS_AND_ANSWERS_INCLUDE_IDENTITY", 1.88 + function(test) { 1.89 + ok(test.pcLocal._last_offer.sdp.contains("a=identity"), "a=identity is in the offer SDP"); 1.90 + ok(test.pcRemote._last_answer.sdp.contains("a=identity"), "a=identity is in the answer SDP"); 1.91 + test.next(); 1.92 + } 1.93 + ], 1.94 + [ 1.95 + "DESCRIPTIONS_CONTAIN_IDENTITY", 1.96 + function(test) { 1.97 + ok(test.pcLocal.localDescription.sdp.contains("a=identity"), 1.98 + "a=identity is in the local copy of the offer"); 1.99 + ok(test.pcRemote.localDescription.sdp.contains("a=identity"), 1.100 + "a=identity is in the remote copy of the offer"); 1.101 + ok(test.pcLocal.remoteDescription.sdp.contains("a=identity"), 1.102 + "a=identity is in the local copy of the answer"); 1.103 + ok(test.pcRemote.remoteDescription.sdp.contains("a=identity"), 1.104 + "a=identity is in the remote copy of the answer"); 1.105 + test.next(); 1.106 + } 1.107 + ] 1.108 + ]); 1.109 + test.run(); 1.110 +} 1.111 +runTest(theTest); 1.112 + 1.113 + 1.114 + 1.115 +</script> 1.116 +</pre> 1.117 +</body> 1.118 +</html>