Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 });
16 makePC = function (config, expect_success) {
17 var exception = null;
18 var pc = null;
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
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 }
39 // This is a test of the iceServers parsing code + readable errors
41 runTest(function () {
42 var pcs = null;
43 var exception = null;
44 var config;
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;
58 makePC(1, false);
60 makePC({}, true);
62 makePC({ iceServers: [] }, true);
64 makePC({ iceServers: [{ url:"" }] }, false);
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);
73 makePC({ iceServers: [{ url:"turns:localhost:3478", username:"p" }] }, false);
75 makePC({ iceServers: [{ url:"turns:localhost:3478", credential:"p" }] }, false);
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;
89 SimpleTest.finish();
90 });
91 </script>
92 </pre>
93 </body>
94 </html>