dom/media/tests/mochitest/test_peerConnection_errorCallbacks.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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="head.js"></script>
     7 </head>
     8 <body>
     9 <pre id="test">
    10 <script type="application/javascript">
    11   createHTML({
    12     bug: "834270",
    13     title: "Align PeerConnection error handling with WebRTC specification"
    14   });
    16   function errorCallback(nextStep) {
    17     return function (err) {
    18       ok(err, "Error is set");
    19       ok(err.name && err.name.length, "Error name = " + err.name);
    20       ok(err.message && err.message.length, "Error message = " + err.message);
    21       nextStep();
    22     }
    23   };
    25   function testCreateAnswerError() {
    26     var pc = new mozRTCPeerConnection();
    27     info ("Testing createAnswer error callback");
    28     pc.createAnswer(generateErrorCallback("createAnswer before offer should fail"),
    29                     errorCallback(testSetLocalDescriptionError));
    30   };
    32   function testSetLocalDescriptionError() {
    33     var pc = new mozRTCPeerConnection();
    34     info ("Testing setLocalDescription error callback");
    35     pc.setLocalDescription(new mozRTCSessionDescription({ sdp: "Picklechips!",
    36                                                           type: "offer" }),
    37       generateErrorCallback("setLocalDescription with nonsense SDP should fail"),
    38       errorCallback(testSetRemoteDescriptionError));
    39   };
    41   function testSetRemoteDescriptionError() {
    42     var pc = new mozRTCPeerConnection();
    43     info ("Testing setRemoteDescription error callback");
    44     pc.setRemoteDescription(new mozRTCSessionDescription({ sdp: "Who?",
    45                                                            type: "offer" }),
    46       generateErrorCallback("setRemoteDescription with nonsense SDP should fail"),
    47       errorCallback(testAddIceCandidateError));
    48   };
    50   function testAddIceCandidateError() {
    51     var pc = new mozRTCPeerConnection();
    52     info ("Testing addIceCandidate error callback");
    53     pc.addIceCandidate(new mozRTCIceCandidate({ candidate: "Pony Lords, jump!",
    54                                                 sdpMid: "whee",
    55                                                 sdpMLineIndex: 1 }),
    56       generateErrorCallback("addIceCandidate with nonsense candidate should fail"),
    57       errorCallback(SimpleTest.finish));
    58   };
    60   // No test for createOffer errors -- there's nothing we can do at this
    61   // level to evoke an error in createOffer.
    63   runTest(function () {
    64     testCreateAnswerError();
    65   });
    66 </script>
    67 </pre>
    68 </body>
    69 </html>

mercurial