dom/media/tests/mochitest/test_peerConnection_bug827843.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/media/tests/mochitest/test_peerConnection_bug827843.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,103 @@
     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="head.js"></script>
    1.10 +  <script type="application/javascript" src="pc.js"></script>
    1.11 +  <script type="application/javascript" src="templates.js"></script>
    1.12 +</head>
    1.13 +<body>
    1.14 +<pre id="test">
    1.15 +<script type="application/javascript">
    1.16 +  createHTML({
    1.17 +    bug: "827843",
    1.18 +    title: "Ensure that localDescription and remoteDescription are null after close"
    1.19 +  });
    1.20 +
    1.21 +  var steps = [
    1.22 +    [
    1.23 +      "CHECK_FOR_SANE_SDP",
    1.24 +      function (test) {
    1.25 +        // TODO: We might want to move those checks into the default chain
    1.26 +        ok(test.pcLocal.localDescription,
    1.27 +           "test.pcLocal.localDescription is not null");
    1.28 +        is(test.pcLocal.localDescription.type, "offer",
    1.29 +           "test.pcLocal.localDescription type is offer");
    1.30 +        ok(test.pcLocal.localDescription.sdp.length > 10,
    1.31 +           "test.pcLocal.localDescription body length is plausible");
    1.32 +
    1.33 +        ok(test.pcLocal.remoteDescription,
    1.34 +           "test.pcLocal.remoteDescription is not null");
    1.35 +        is(test.pcLocal.remoteDescription.type, "answer",
    1.36 +            "test.pcLocal.remoteDescription type is answer");
    1.37 +        ok(test.pcLocal.remoteDescription.sdp.length > 10,
    1.38 +           "test.pcLocal.remoteDescription body length is plausible");
    1.39 +
    1.40 +        ok(test.pcRemote.localDescription,
    1.41 +           "test.pcRemote.localDescription is not null");
    1.42 +        is(test.pcRemote.localDescription.type, "answer",
    1.43 +           "test.pcRemote.localDescription type is answer");
    1.44 +        ok(test.pcRemote.localDescription.sdp.length > 10,
    1.45 +           "test.pcRemote.localDescription body length is plausible");
    1.46 +
    1.47 +        ok(test.pcRemote.remoteDescription,
    1.48 +           "test.pcRemote.remoteDescription is not null");
    1.49 +        is(test.pcRemote.remoteDescription.type, "offer",
    1.50 +           "test.pcRemote.remoteDescription type is offer");
    1.51 +        ok(test.pcRemote.remoteDescription.sdp.length > 10,
    1.52 +           "test.pcRemote.remoteDescription body length is plausible");
    1.53 +
    1.54 +        test.next();
    1.55 +      }
    1.56 +    ], [
    1.57 +      "CHECK_SDP_ON_CLOSED_PC",
    1.58 +      function (test) {
    1.59 +        var description;
    1.60 +        var exception = null;
    1.61 +
    1.62 +        // handle the event which the close() triggers
    1.63 +        test.pcLocal.onsignalingstatechange = function (state) {
    1.64 +          is(state, "closed", "Received expected onsignalingstatechange event 'closed'");
    1.65 +        }
    1.66 +
    1.67 +        test.pcLocal.close();
    1.68 +
    1.69 +        try { description = test.pcLocal.localDescription; } catch (e) { exception = e; }
    1.70 +        ok(exception, "Attempt to access localDescription of pcLocal after close throws exception");
    1.71 +        exception = null;
    1.72 +
    1.73 +        try { description = test.pcLocal.remoteDescription; } catch (e) { exception = e; }
    1.74 +        ok(exception, "Attempt to access remoteDescription of pcLocal after close throws exception");
    1.75 +        exception = null;
    1.76 +
    1.77 +        // handle the event which the close() triggers
    1.78 +        test.pcRemote.onsignalingstatechange = function (state) {
    1.79 +          is(state, "closed", "Received expected onsignalingstatechange event 'closed'");
    1.80 +        }
    1.81 +
    1.82 +        test.pcRemote.close();
    1.83 +
    1.84 +        try  { description = test.pcRemote.localDescription; } catch (e) { exception = e; }
    1.85 +        ok(exception, "Attempt to access localDescription of pcRemote after close throws exception");
    1.86 +        exception = null;
    1.87 +
    1.88 +        try  { description = test.pcRemote.remoteDescription; } catch (e) { exception = e; }
    1.89 +        ok(exception, "Attempt to access remoteDescription of pcRemote after close throws exception");
    1.90 +
    1.91 +        test.next();
    1.92 +      }
    1.93 +    ]
    1.94 +  ];
    1.95 +
    1.96 +  var test;
    1.97 +  runTest(function () {
    1.98 +    test = new PeerConnectionTest();
    1.99 +    test.setMediaConstraints([{audio: true}], [{audio: true}]);
   1.100 +    test.chain.append(steps);
   1.101 +    test.run();
   1.102 +  });
   1.103 +</script>
   1.104 +</pre>
   1.105 +</body>
   1.106 +</html>

mercurial