test_peerConnection_stats_relayProtocol.html (2391B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <script type="application/javascript" src="nonTrickleIce.js"></script> 5 <script type="application/javascript" src="pc.js"></script> 6 </head> 7 <body> 8 <pre id="test"> 9 <script type="application/javascript"> 10 createHTML({ 11 bug: "1435789", 12 title: "WebRTC local-candidate relayProtocol stats attribute" 13 }); 14 15 // This test uses the NAT simulator in order to get srflx candidates. 16 // It doesn't work in https, so we turn on getUserMedia in http, which requires 17 // a reload. 18 if (!("mediaDevices" in navigator)) { 19 SpecialPowers.pushPrefEnv({set: [['media.devices.insecure.enabled', true]]}, 20 () => location.reload()); 21 } else { 22 runNetworkTest(async (options = {}) => { 23 await pushPrefs( 24 ['media.peerconnection.nat_simulator.filtering_type', 'ENDPOINT_INDEPENDENT'], 25 ['media.peerconnection.nat_simulator.mapping_type', 'ENDPOINT_INDEPENDENT'], 26 ['media.peerconnection.ice.loopback', true], 27 // The above triggers warning about 5 ICE servers 28 ['media.peerconnection.treat_warnings_as_errors', false], 29 ['media.getusermedia.insecure.enabled', true]); 30 const test = new PeerConnectionTest(options); 31 makeOffererNonTrickle(test.chain); 32 makeAnswererNonTrickle(test.chain); 33 34 test.chain.removeAfter("PC_LOCAL_WAIT_FOR_MEDIA_FLOW"); 35 test.chain.append([PC_LOCAL_TEST_LOCAL_STATS_RELAYCANDIDATE]); 36 37 test.setMediaConstraints([{ audio: true }], [{ audio: true }]); 38 await test.run(); 39 }, { useIceServer: true }); 40 } 41 42 const PC_LOCAL_TEST_LOCAL_STATS_RELAYCANDIDATE = test => { 43 return test.pcLocal.getStats().then(stats => { 44 let haveRelayProtocol = {}; 45 for (let [k, v] of stats) { 46 if (v.type == "local-candidate") { 47 haveRelayProtocol[v.candidateType + "-" + v.relayProtocol] = v.relayProtocol; 48 } 49 } 50 is(haveRelayProtocol["host-undefined"], undefined, "relayProtocol not set for host candidates"); 51 is(haveRelayProtocol["srflx-undefined"], undefined, "relayProtocol not set for server reflexive candidates"); 52 ok(haveRelayProtocol["relay-udp"], "Has UDP relay candidate"); 53 ok(haveRelayProtocol["relay-tcp"], "Has TCP relay candidate"); 54 ok(haveRelayProtocol["relay-tls"], "Has TLS relay candidate"); 55 ok(Object.keys(haveRelayProtocol).length >= 5, "All candidate types are accounted for"); 56 }); 57 } 58 </script> 59 </pre> 60 </body> 61 </html>