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