dom/media/tests/mochitest/test_peerConnection_errorCallbacks.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_errorCallbacks.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,69 @@
     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 +</head>
    1.11 +<body>
    1.12 +<pre id="test">
    1.13 +<script type="application/javascript">
    1.14 +  createHTML({
    1.15 +    bug: "834270",
    1.16 +    title: "Align PeerConnection error handling with WebRTC specification"
    1.17 +  });
    1.18 +
    1.19 +  function errorCallback(nextStep) {
    1.20 +    return function (err) {
    1.21 +      ok(err, "Error is set");
    1.22 +      ok(err.name && err.name.length, "Error name = " + err.name);
    1.23 +      ok(err.message && err.message.length, "Error message = " + err.message);
    1.24 +      nextStep();
    1.25 +    }
    1.26 +  };
    1.27 +
    1.28 +  function testCreateAnswerError() {
    1.29 +    var pc = new mozRTCPeerConnection();
    1.30 +    info ("Testing createAnswer error callback");
    1.31 +    pc.createAnswer(generateErrorCallback("createAnswer before offer should fail"),
    1.32 +                    errorCallback(testSetLocalDescriptionError));
    1.33 +  };
    1.34 +
    1.35 +  function testSetLocalDescriptionError() {
    1.36 +    var pc = new mozRTCPeerConnection();
    1.37 +    info ("Testing setLocalDescription error callback");
    1.38 +    pc.setLocalDescription(new mozRTCSessionDescription({ sdp: "Picklechips!",
    1.39 +                                                          type: "offer" }),
    1.40 +      generateErrorCallback("setLocalDescription with nonsense SDP should fail"),
    1.41 +      errorCallback(testSetRemoteDescriptionError));
    1.42 +  };
    1.43 +
    1.44 +  function testSetRemoteDescriptionError() {
    1.45 +    var pc = new mozRTCPeerConnection();
    1.46 +    info ("Testing setRemoteDescription error callback");
    1.47 +    pc.setRemoteDescription(new mozRTCSessionDescription({ sdp: "Who?",
    1.48 +                                                           type: "offer" }),
    1.49 +      generateErrorCallback("setRemoteDescription with nonsense SDP should fail"),
    1.50 +      errorCallback(testAddIceCandidateError));
    1.51 +  };
    1.52 +
    1.53 +  function testAddIceCandidateError() {
    1.54 +    var pc = new mozRTCPeerConnection();
    1.55 +    info ("Testing addIceCandidate error callback");
    1.56 +    pc.addIceCandidate(new mozRTCIceCandidate({ candidate: "Pony Lords, jump!",
    1.57 +                                                sdpMid: "whee",
    1.58 +                                                sdpMLineIndex: 1 }),
    1.59 +      generateErrorCallback("addIceCandidate with nonsense candidate should fail"),
    1.60 +      errorCallback(SimpleTest.finish));
    1.61 +  };
    1.62 +
    1.63 +  // No test for createOffer errors -- there's nothing we can do at this
    1.64 +  // level to evoke an error in createOffer.
    1.65 +
    1.66 +  runTest(function () {
    1.67 +    testCreateAnswerError();
    1.68 +  });
    1.69 +</script>
    1.70 +</pre>
    1.71 +</body>
    1.72 +</html>

mercurial