Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- Manifest: dom/media/webrtc/tests/mochitests/mochitest_peerconnection.toml
<!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'],
// The above triggers warning about 5 ICE servers
['media.peerconnection.treat_warnings_as_errors', false],
['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>