1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/media/tests/mochitest/test_peerConnection_bug825703.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,94 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.8 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.9 + <script type="application/javascript" src="head.js"></script> 1.10 +</head> 1.11 +<body> 1.12 +<pre id="test"> 1.13 +<script type="application/javascript"> 1.14 + createHTML({ 1.15 + bug: "825703", 1.16 + title: "RTCConfiguration valid/invalid permutations" 1.17 + }); 1.18 + 1.19 + makePC = function (config, expect_success) { 1.20 + var exception = null; 1.21 + var pc = null; 1.22 + 1.23 + try { 1.24 + pc = new mozRTCPeerConnection(config); 1.25 + } catch (e) { 1.26 + exception = e; 1.27 + } 1.28 + if (pc !== null) { 1.29 + pc.close(); 1.30 + } 1.31 + pc = null 1.32 + 1.33 + if (expect_success) { 1.34 + ok(!exception, "mozRTCPeerConnection(" + 1.35 + JSON.stringify(config) + ") succeeds"); 1.36 + } else { 1.37 + ok(exception, "mozRTCPeerConnection(" + 1.38 + JSON.stringify(config) + ") throws"); 1.39 + } 1.40 + } 1.41 + 1.42 + // This is a test of the iceServers parsing code + readable errors 1.43 + 1.44 + runTest(function () { 1.45 + var pcs = null; 1.46 + var exception = null; 1.47 + var config; 1.48 + 1.49 + try { 1.50 + pcs = new mozRTCPeerConnection(); 1.51 + } catch (e) { 1.52 + exception = e; 1.53 + } 1.54 + ok(!exception, "mozRTCPeerConnection() succeeds"); 1.55 + if (pcs !== null) { 1.56 + pcs.close(); 1.57 + } 1.58 + pcs = null; 1.59 + exception = null; 1.60 + 1.61 + makePC(1, false); 1.62 + 1.63 + makePC({}, true); 1.64 + 1.65 + makePC({ iceServers: [] }, true); 1.66 + 1.67 + makePC({ iceServers: [{ url:"" }] }, false); 1.68 + 1.69 + makePC({ iceServers: [ 1.70 + { url:"stun:127.0.0.1" }, 1.71 + { url:"stuns:localhost", foo:"" }, 1.72 + { url:"turn:[::1]:3478", username:"p", credential:"p" }, 1.73 + { url:"turns:localhost:3478?transport=udp", username:"p", credential:"p" } 1.74 + ]}, true); 1.75 + 1.76 + makePC({ iceServers: [{ url:"turns:localhost:3478", username:"p" }] }, false); 1.77 + 1.78 + makePC({ iceServers: [{ url:"turns:localhost:3478", credential:"p" }] }, false); 1.79 + 1.80 + makePC({ iceServers: [{ url:"http:0.0.0.0" }] }, false); 1.81 + try { 1.82 + pcs = new mozRTCPeerConnection({ iceServers: [{ url:"http:0.0.0.0" }] }); 1.83 + } catch (e) { 1.84 + ok(e.message.indexOf("http") > 0, 1.85 + "mozRTCPeerConnection() constructor has readable exceptions"); 1.86 + } 1.87 + if (pcs !== null) { 1.88 + pcs.close(); 1.89 + } 1.90 + pcs = null; 1.91 + 1.92 + SimpleTest.finish(); 1.93 + }); 1.94 +</script> 1.95 +</pre> 1.96 +</body> 1.97 +</html>