test_peerConnection_portRestrictions.html (2299B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <script type="application/javascript" src="pc.js"></script> 5 </head> 6 <body> 7 <pre id="test"> 8 <script type="application/javascript"> 9 createHTML({ 10 bug: "1677046", 11 title: "RTCPeerConnection check restricted ports" 12 }); 13 14 var makePC = (config, expected_error) => { 15 var exception; 16 try { 17 new RTCPeerConnection(config).close(); 18 } catch (e) { 19 exception = e; 20 } 21 is((exception? exception.name : "success"), expected_error || "success", 22 "RTCPeerConnection(" + JSON.stringify(config) + ")"); 23 }; 24 25 // This is a test of the iceServers parsing code + readable errors 26 runNetworkTest(() => { 27 var exception = null; 28 29 // check various ports on the blocklist 30 makePC({ iceServers: [ 31 { urls:"turn:[::1]:6666", username:"p", credential:"p" }] }, "NS_ERROR_UNEXPECTED"); 32 makePC({ iceServers: [ 33 { urls:"turns:localhost:6667?transport=udp", username:"p", credential:"p" }] }, 34 "NS_ERROR_UNEXPECTED"); 35 makePC({ iceServers: [ 36 { urls:"stun:localhost:21", foo:"" }] }, "NS_ERROR_UNEXPECTED"); 37 makePC({ iceServers: [ 38 { urls:"stun:[::1]:22", foo:"" }] }, "NS_ERROR_UNEXPECTED"); 39 makePC({ iceServers: [ 40 { urls:"turn:localhost:5060", username:"p", credential:"p" }] }, 41 "NS_ERROR_UNEXPECTED"); 42 43 // check various ports on the good list for webrtc (or default port) 44 makePC({ iceServers: [ 45 { urls:"turn:[::1]:53", username:"p", credential:"p" }, 46 { urls:"turn:[::1]:5349", username:"p", credential:"p" }, 47 { urls:"turn:[::1]:3478", username:"p", credential:"p" }, 48 { urls:"turn:[::1]", username:"p", credential:"p" }, 49 ]}); 50 makePC({ iceServers: [ 51 { urls:"turn:localhost:53?transport=udp", username:"p", credential:"p" }, 52 { urls:"turn:localhost:3478?transport=udp", username:"p", credential:"p" }, 53 { urls:"turn:localhost:53?transport=tcp", username:"p", credential:"p" }, 54 { urls:"turn:localhost:3478?transport=tcp", username:"p", credential:"p" }, 55 ]}); 56 makePC({ iceServers: [ 57 { urls:"turns:localhost:3478?transport=udp", username:"p", credential:"p" }, 58 { urls:"stun:localhost", foo:"" } 59 ]}); 60 61 // not in the known good ports and not on the generic block list 62 makePC({ iceServers: [{ urls:"turn:localhost:6664", username:"p", credential:"p" }] }); 63 }); 64 </script> 65 </pre> 66 </body> 67 </html>