dom/media/tests/identity/test_setIdentityProviderWithErrors.html

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:a96531d2f19a
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
5 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
6 <script type="application/javascript" src="../mochitest/head.js"></script>
7 <script type="application/javascript" src="../mochitest/pc.js"></script>
8 <script type="application/javascript" src="../mochitest/templates.js"></script>
9 <script type="application/javascript" src="identityevent.js"></script>
10 </head>
11 <body>
12 <pre id="test">
13 <script type="application/javascript">
14 createHTML({
15 title: "Identity Provider returning errors is handled correctly"
16 });
17
18 var test;
19 runTest(function () {
20 test = new PeerConnectionTest();
21 test.setMediaConstraints([{audio: true}], [{audio: true}]);
22 // first example generates an error
23 test.setIdentityProvider(test.pcLocal, 'example.com', 'idp.html#error', 'nobody');
24 // second generates a bad assertion; which fails to validate
25 test.setIdentityProvider(test.pcRemote, 'example.com', 'idp.html#bad', 'nobody');
26
27 var localEvents = trapIdentityEvents(test.pcLocal._pc);
28 var remoteEvents = trapIdentityEvents(test.pcRemote._pc);
29
30 test.chain.append([
31 [
32 'CHECK_IDENTITY_EVENTS',
33 function(test) {
34 function checkEvents() {
35 ok(localEvents.idpassertionerror, 'local assertion generation should fail (idpassertionerror)');
36 is(localEvents.idpassertionerror.idp, 'example.com', 'event IdP is correct');
37 is(localEvents.idpassertionerror.protocol, 'idp.html#error', 'event IdP protocol is #error');
38 ok(!remoteEvents.idpassertionerror, 'remote assertion generation should succeed (idpassertionerror)');
39 ok(!localEvents.identityresult, 'local assertion generation should fail (identityresult)');
40 ok(remoteEvents.identityresult, 'remote assertion generation should succeed (identityresult)');
41
42 ok(!localEvents.peeridentity, 'no peer identity event for local peer');
43 ok(!remoteEvents.peeridentity, 'no peer identity event for remote peer');
44 ok(localEvents.idpvalidationerror, 'local fails to validate');
45 is(localEvents.idpvalidationerror.idp, 'example.com', 'event IdP is correct');
46 is(localEvents.idpvalidationerror.protocol, 'idp.html#bad', 'event IdP protocol is #bad');
47 ok(!remoteEvents.idpvalidationerror, 'remote doesn\'t even see an assertion');
48
49 test.next();
50 }
51
52 // we actually have to wait on this because IdP validation happens asynchronously
53 if (localEvents.idpvalidationerror) {
54 checkEvents();
55 } else {
56 // have to let the other event handler have a chance to record success
57 // before we run the checks that rely on that recording
58 test.pcLocal._pc.onidpvalidationerror = setTimeout.bind(window, checkEvents, 1);
59 }
60 }
61 ],
62 [
63 'PEER_IDENTITY_IS_EMPTY',
64 function(test) {
65 ok(!test.pcLocal._pc.peerIdentity, 'local peerIdentity is not set');
66 ok(!test.pcRemote._pc.peerIdentity, 'remote peerIdentity is not set');
67 test.next();
68 }
69 ],
70 [
71 'ONLY_REMOTE_SDP_INCLUDES_IDENTITY_ASSERTION',
72 function(test) {
73 ok(!test.pcLocal._last_offer.sdp.contains('a=identity'), 'a=identity not contained in the offer SDP');
74 ok(test.pcRemote._last_answer.sdp.contains('a=identity'), 'a=identity is contained in the answer SDP');
75 test.next();
76 }
77 ]
78 ]);
79 test.run();
80 });
81
82 </script>
83 </pre>
84 </body>
85 </html>

mercurial