test_peerConnection_errorCallbacks.html (1650B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <script type="application/javascript" src="pc.js"></script> 5 </head> 6 <body> 7 <pre id="test"> 8 <script type="application/javascript"> 9 createHTML({ 10 bug: "834270", 11 title: "Align PeerConnection error handling with WebRTC specification" 12 }); 13 14 function validateReason(reason) { 15 ok(reason.name.length, "Reason name = " + reason.name); 16 ok(reason.message.length, "Reason message = " + reason.message); 17 }; 18 19 function testCreateAnswerError() { 20 var pc = new RTCPeerConnection(); 21 info ("Testing createAnswer error"); 22 return pc.createAnswer() 23 .then(generateErrorCallback("createAnswer before offer should fail"), 24 validateReason); 25 }; 26 27 function testSetLocalDescriptionError() { 28 var pc = new RTCPeerConnection(); 29 info ("Testing setLocalDescription error"); 30 return pc.setLocalDescription({ sdp: "Picklechips!", type: "offer" }) 31 .then(generateErrorCallback("setLocalDescription with nonsense SDP should fail"), 32 validateReason); 33 }; 34 35 function testSetRemoteDescriptionError() { 36 var pc = new RTCPeerConnection(); 37 info ("Testing setRemoteDescription error"); 38 return pc.setRemoteDescription({ sdp: "Who?", type: "offer" }) 39 .then(generateErrorCallback("setRemoteDescription with nonsense SDP should fail"), 40 validateReason); 41 }; 42 43 // No test for createOffer errors -- there's nothing we can do at this 44 // level to evoke an error in createOffer. 45 46 runNetworkTest(function () { 47 return testCreateAnswerError() 48 .then(testSetLocalDescriptionError) 49 .then(testSetRemoteDescriptionError); 50 }); 51 52 </script> 53 </pre> 54 </body> 55 </html>