dom/media/tests/identity/test_setIdentityProviderWithErrors.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/media/tests/identity/test_setIdentityProviderWithErrors.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,85 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     1.8 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +  <script type="application/javascript" src="../mochitest/head.js"></script>
    1.10 +  <script type="application/javascript" src="../mochitest/pc.js"></script>
    1.11 +  <script type="application/javascript" src="../mochitest/templates.js"></script>
    1.12 +  <script type="application/javascript" src="identityevent.js"></script>
    1.13 +</head>
    1.14 +<body>
    1.15 +<pre id="test">
    1.16 +<script type="application/javascript">
    1.17 +  createHTML({
    1.18 +    title: "Identity Provider returning errors is handled correctly"
    1.19 +  });
    1.20 +
    1.21 +var test;
    1.22 +runTest(function () {
    1.23 +  test = new PeerConnectionTest();
    1.24 +  test.setMediaConstraints([{audio: true}], [{audio: true}]);
    1.25 +  // first example generates an error
    1.26 +  test.setIdentityProvider(test.pcLocal, 'example.com', 'idp.html#error', 'nobody');
    1.27 +  // second generates a bad assertion; which fails to validate
    1.28 +  test.setIdentityProvider(test.pcRemote, 'example.com', 'idp.html#bad', 'nobody');
    1.29 +
    1.30 +  var localEvents = trapIdentityEvents(test.pcLocal._pc);
    1.31 +  var remoteEvents = trapIdentityEvents(test.pcRemote._pc);
    1.32 +
    1.33 +  test.chain.append([
    1.34 +    [
    1.35 +      'CHECK_IDENTITY_EVENTS',
    1.36 +      function(test) {
    1.37 +        function checkEvents() {
    1.38 +          ok(localEvents.idpassertionerror, 'local assertion generation should fail (idpassertionerror)');
    1.39 +          is(localEvents.idpassertionerror.idp, 'example.com', 'event IdP is correct');
    1.40 +          is(localEvents.idpassertionerror.protocol, 'idp.html#error', 'event IdP protocol is #error');
    1.41 +          ok(!remoteEvents.idpassertionerror, 'remote assertion generation should succeed (idpassertionerror)');
    1.42 +          ok(!localEvents.identityresult, 'local assertion generation should fail (identityresult)');
    1.43 +          ok(remoteEvents.identityresult, 'remote assertion generation should succeed (identityresult)');
    1.44 +
    1.45 +          ok(!localEvents.peeridentity, 'no peer identity event for local peer');
    1.46 +          ok(!remoteEvents.peeridentity, 'no peer identity event for remote peer');
    1.47 +          ok(localEvents.idpvalidationerror, 'local fails to validate');
    1.48 +          is(localEvents.idpvalidationerror.idp, 'example.com', 'event IdP is correct');
    1.49 +          is(localEvents.idpvalidationerror.protocol, 'idp.html#bad', 'event IdP protocol is #bad');
    1.50 +          ok(!remoteEvents.idpvalidationerror, 'remote doesn\'t even see an assertion');
    1.51 +
    1.52 +          test.next();
    1.53 +        }
    1.54 +
    1.55 +        // we actually have to wait on this because IdP validation happens asynchronously
    1.56 +        if (localEvents.idpvalidationerror) {
    1.57 +          checkEvents();
    1.58 +        } else {
    1.59 +          // have to let the other event handler have a chance to record success
    1.60 +          // before we run the checks that rely on that recording
    1.61 +          test.pcLocal._pc.onidpvalidationerror = setTimeout.bind(window, checkEvents, 1);
    1.62 +        }
    1.63 +      }
    1.64 +    ],
    1.65 +    [
    1.66 +      'PEER_IDENTITY_IS_EMPTY',
    1.67 +      function(test) {
    1.68 +        ok(!test.pcLocal._pc.peerIdentity, 'local peerIdentity is not set');
    1.69 +        ok(!test.pcRemote._pc.peerIdentity, 'remote peerIdentity is not set');
    1.70 +        test.next();
    1.71 +      }
    1.72 +    ],
    1.73 +    [
    1.74 +      'ONLY_REMOTE_SDP_INCLUDES_IDENTITY_ASSERTION',
    1.75 +      function(test) {
    1.76 +        ok(!test.pcLocal._last_offer.sdp.contains('a=identity'), 'a=identity not contained in the offer SDP');
    1.77 +        ok(test.pcRemote._last_answer.sdp.contains('a=identity'), 'a=identity is contained in the answer SDP');
    1.78 +        test.next();
    1.79 +      }
    1.80 +    ]
    1.81 +  ]);
    1.82 +  test.run();
    1.83 +});
    1.84 +
    1.85 +</script>
    1.86 +</pre>
    1.87 +</body>
    1.88 +</html>

mercurial