dom/media/tests/identity/test_setIdentityProvider.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <meta charset="utf-8"/>
michael@0 5 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 6 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 7 <script type="application/javascript" src="../mochitest/head.js"></script>
michael@0 8 <script type="application/javascript" src="../mochitest/pc.js"></script>
michael@0 9 <script type="application/javascript" src="../mochitest/templates.js"></script>
michael@0 10 <script type="application/javascript" src="identityevent.js"></script>
michael@0 11 </head>
michael@0 12 <body>
michael@0 13 <pre id="test">
michael@0 14 <script type="application/javascript">
michael@0 15 createHTML({
michael@0 16 title: "setIdentityProvider leads to peerIdentity and assertions in SDP"
michael@0 17 });
michael@0 18
michael@0 19 var test;
michael@0 20 function theTest() {
michael@0 21 test = new PeerConnectionTest();
michael@0 22 test.setMediaConstraints([{audio: true}], [{audio: true}]);
michael@0 23 test.setIdentityProvider(test.pcLocal, "test1.example.com", "idp.html", "someone");
michael@0 24 test.setIdentityProvider(test.pcRemote, "test2.example.com", "idp.html", "someone");
michael@0 25
michael@0 26 var localEvents = trapIdentityEvents(test.pcLocal._pc);
michael@0 27 var remoteEvents = trapIdentityEvents(test.pcRemote._pc);
michael@0 28
michael@0 29 test.chain.append([
michael@0 30 [
michael@0 31 "PEER_IDENTITY_IS_SET_CORRECTLY",
michael@0 32 function(test) {
michael@0 33 var outstanding = 0;
michael@0 34 // we have to wait for the identity result in order to get the actual
michael@0 35 // identity information, since the call will complete before the identity
michael@0 36 // provider has a chance to finish verifying... that's OK, but it makes
michael@0 37 // testing more difficult
michael@0 38
michael@0 39 function checkOrSetupCheck(pc, pfx, idp, name) {
michael@0 40 function checkIdentity() {
michael@0 41 ok(pc.peerIdentity, pfx + "peerIdentity is set");
michael@0 42 is(pc.peerIdentity.idp, idp, pfx + "IdP is correct");
michael@0 43 is(pc.peerIdentity.name, name + "@" + idp, pfx + "identity is correct");
michael@0 44 }
michael@0 45 if (pc.peerIdentity) {
michael@0 46 info(pfx + "peerIdentity already set");
michael@0 47 checkIdentity();
michael@0 48 } else {
michael@0 49 ++outstanding;
michael@0 50 info(pfx + "setting onpeeridentity handler");
michael@0 51 pc.onpeeridentity = function checkIdentityEvent(e) {
michael@0 52 info(pfx + "checking peerIdentity");
michael@0 53 checkIdentity();
michael@0 54 --outstanding;
michael@0 55 if (outstanding <= 0) {
michael@0 56 test.next();
michael@0 57 }
michael@0 58 };
michael@0 59 }
michael@0 60 }
michael@0 61
michael@0 62 checkOrSetupCheck(test.pcLocal._pc, "local: ", "test2.example.com", "someone");
michael@0 63 checkOrSetupCheck(test.pcRemote._pc, "remote: ", "test1.example.com", "someone");
michael@0 64 if (outstanding <= 0) {
michael@0 65 test.next();
michael@0 66 }
michael@0 67 }
michael@0 68 ],
michael@0 69 [
michael@0 70 "CHECK_IDENTITY_EVENTS",
michael@0 71 function(test) {
michael@0 72 ok(!localEvents.idpassertionerror , "No assertion generation errors on local");
michael@0 73 ok(!remoteEvents.idpassertionerror, "No assertion generation errors on remote");
michael@0 74 ok(!localEvents.idpvalidationerror, "No assertion validation errors on local");
michael@0 75 ok( !remoteEvents.idpvalidationerror, "No assertion validation errors on remote");
michael@0 76 ok(localEvents.identityresult, "local acquired identity assertions");
michael@0 77 ok(remoteEvents.identityresult, "remote acquired identity assertions");
michael@0 78 ok(localEvents.peeridentity, "local got peer identity");
michael@0 79 ok(remoteEvents.peeridentity, "remote got peer identity");
michael@0 80 test.next();
michael@0 81 }
michael@0 82 ],
michael@0 83 [
michael@0 84 "OFFERS_AND_ANSWERS_INCLUDE_IDENTITY",
michael@0 85 function(test) {
michael@0 86 ok(test.pcLocal._last_offer.sdp.contains("a=identity"), "a=identity is in the offer SDP");
michael@0 87 ok(test.pcRemote._last_answer.sdp.contains("a=identity"), "a=identity is in the answer SDP");
michael@0 88 test.next();
michael@0 89 }
michael@0 90 ],
michael@0 91 [
michael@0 92 "DESCRIPTIONS_CONTAIN_IDENTITY",
michael@0 93 function(test) {
michael@0 94 ok(test.pcLocal.localDescription.sdp.contains("a=identity"),
michael@0 95 "a=identity is in the local copy of the offer");
michael@0 96 ok(test.pcRemote.localDescription.sdp.contains("a=identity"),
michael@0 97 "a=identity is in the remote copy of the offer");
michael@0 98 ok(test.pcLocal.remoteDescription.sdp.contains("a=identity"),
michael@0 99 "a=identity is in the local copy of the answer");
michael@0 100 ok(test.pcRemote.remoteDescription.sdp.contains("a=identity"),
michael@0 101 "a=identity is in the remote copy of the answer");
michael@0 102 test.next();
michael@0 103 }
michael@0 104 ]
michael@0 105 ]);
michael@0 106 test.run();
michael@0 107 }
michael@0 108 runTest(theTest);
michael@0 109
michael@0 110
michael@0 111
michael@0 112 </script>
michael@0 113 </pre>
michael@0 114 </body>
michael@0 115 </html>

mercurial