dom/media/tests/mochitest/test_peerConnection_bug825703.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial