diff options
Diffstat (limited to 'dom/media/webrtc/tests/mochitests/test_peerConnection_stats_relayProtocol.html')
-rw-r--r-- | dom/media/webrtc/tests/mochitests/test_peerConnection_stats_relayProtocol.html | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/dom/media/webrtc/tests/mochitests/test_peerConnection_stats_relayProtocol.html b/dom/media/webrtc/tests/mochitests/test_peerConnection_stats_relayProtocol.html new file mode 100644 index 0000000000..cdc328fd2b --- /dev/null +++ b/dom/media/webrtc/tests/mochitests/test_peerConnection_stats_relayProtocol.html @@ -0,0 +1,58 @@ +<!DOCTYPE HTML> +<html> +<head> + <script type="application/javascript" src="nonTrickleIce.js"></script> + <script type="application/javascript" src="pc.js"></script> +</head> +<body> +<pre id="test"> +<script type="application/javascript"> +createHTML({ + bug: "1435789", + title: "WebRTC local-candidate relayProtocol stats attribute" +}); + +// This test uses the NAT simulator in order to get srflx candidates. +// It doesn't work in https, so we turn on getUserMedia in http, which requires +// a reload. +if (!("mediaDevices" in navigator)) { + SpecialPowers.pushPrefEnv({set: [['media.devices.insecure.enabled', true]]}, + () => location.reload()); +} else { + runNetworkTest(async (options = {}) => { + await pushPrefs( + ['media.peerconnection.nat_simulator.filtering_type', 'ENDPOINT_INDEPENDENT'], + ['media.peerconnection.nat_simulator.mapping_type', 'ENDPOINT_INDEPENDENT'], + ['media.getusermedia.insecure.enabled', true]); + const test = new PeerConnectionTest(options); + makeOffererNonTrickle(test.chain); + makeAnswererNonTrickle(test.chain); + + test.chain.removeAfter("PC_LOCAL_WAIT_FOR_MEDIA_FLOW"); + test.chain.append([PC_LOCAL_TEST_LOCAL_STATS_RELAYCANDIDATE]); + + test.setMediaConstraints([{ audio: true }], [{ audio: true }]); + await test.run(); + }, { useIceServer: true }); +} + +const PC_LOCAL_TEST_LOCAL_STATS_RELAYCANDIDATE = test => { + return test.pcLocal.getStats().then(stats => { + let haveRelayProtocol = {}; + for (let [k, v] of stats) { + if (v.type == "local-candidate") { + haveRelayProtocol[v.candidateType + "-" + v.relayProtocol] = v.relayProtocol; + } + } + is(haveRelayProtocol["host-undefined"], undefined, "relayProtocol not set for host candidates"); + is(haveRelayProtocol["srflx-undefined"], undefined, "relayProtocol not set for server reflexive candidates"); + ok(haveRelayProtocol["relay-udp"], "Has UDP relay candidate"); + ok(haveRelayProtocol["relay-tcp"], "Has TCP relay candidate"); + ok(haveRelayProtocol["relay-tls"], "Has TLS relay candidate"); + is(Object.keys(haveRelayProtocol).length, 5, "All candidate types are accounted for"); + }); +} +</script> +</pre> +</body> +</html> |