|
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: "825703", |
|
13 title: "RTCConfiguration valid/invalid permutations" |
|
14 }); |
|
15 |
|
16 makePC = function (config, expect_success) { |
|
17 var exception = null; |
|
18 var pc = null; |
|
19 |
|
20 try { |
|
21 pc = new mozRTCPeerConnection(config); |
|
22 } catch (e) { |
|
23 exception = e; |
|
24 } |
|
25 if (pc !== null) { |
|
26 pc.close(); |
|
27 } |
|
28 pc = null |
|
29 |
|
30 if (expect_success) { |
|
31 ok(!exception, "mozRTCPeerConnection(" + |
|
32 JSON.stringify(config) + ") succeeds"); |
|
33 } else { |
|
34 ok(exception, "mozRTCPeerConnection(" + |
|
35 JSON.stringify(config) + ") throws"); |
|
36 } |
|
37 } |
|
38 |
|
39 // This is a test of the iceServers parsing code + readable errors |
|
40 |
|
41 runTest(function () { |
|
42 var pcs = null; |
|
43 var exception = null; |
|
44 var config; |
|
45 |
|
46 try { |
|
47 pcs = new mozRTCPeerConnection(); |
|
48 } catch (e) { |
|
49 exception = e; |
|
50 } |
|
51 ok(!exception, "mozRTCPeerConnection() succeeds"); |
|
52 if (pcs !== null) { |
|
53 pcs.close(); |
|
54 } |
|
55 pcs = null; |
|
56 exception = null; |
|
57 |
|
58 makePC(1, false); |
|
59 |
|
60 makePC({}, true); |
|
61 |
|
62 makePC({ iceServers: [] }, true); |
|
63 |
|
64 makePC({ iceServers: [{ url:"" }] }, false); |
|
65 |
|
66 makePC({ iceServers: [ |
|
67 { url:"stun:127.0.0.1" }, |
|
68 { url:"stuns:localhost", foo:"" }, |
|
69 { url:"turn:[::1]:3478", username:"p", credential:"p" }, |
|
70 { url:"turns:localhost:3478?transport=udp", username:"p", credential:"p" } |
|
71 ]}, true); |
|
72 |
|
73 makePC({ iceServers: [{ url:"turns:localhost:3478", username:"p" }] }, false); |
|
74 |
|
75 makePC({ iceServers: [{ url:"turns:localhost:3478", credential:"p" }] }, false); |
|
76 |
|
77 makePC({ iceServers: [{ url:"http:0.0.0.0" }] }, false); |
|
78 try { |
|
79 pcs = new mozRTCPeerConnection({ iceServers: [{ url:"http:0.0.0.0" }] }); |
|
80 } catch (e) { |
|
81 ok(e.message.indexOf("http") > 0, |
|
82 "mozRTCPeerConnection() constructor has readable exceptions"); |
|
83 } |
|
84 if (pcs !== null) { |
|
85 pcs.close(); |
|
86 } |
|
87 pcs = null; |
|
88 |
|
89 SimpleTest.finish(); |
|
90 }); |
|
91 </script> |
|
92 </pre> |
|
93 </body> |
|
94 </html> |