|
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 }); |
|
15 |
|
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 }; |
|
24 |
|
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 }; |
|
31 |
|
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 }; |
|
40 |
|
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 }; |
|
49 |
|
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 }; |
|
59 |
|
60 // No test for createOffer errors -- there's nothing we can do at this |
|
61 // level to evoke an error in createOffer. |
|
62 |
|
63 runTest(function () { |
|
64 testCreateAnswerError(); |
|
65 }); |
|
66 </script> |
|
67 </pre> |
|
68 </body> |
|
69 </html> |