diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/media/webrtc/tests/mochitests/test_peerConnection_basicAudioRelayPolicy.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/webrtc/tests/mochitests/test_peerConnection_basicAudioRelayPolicy.html')
-rw-r--r-- | dom/media/webrtc/tests/mochitests/test_peerConnection_basicAudioRelayPolicy.html | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/dom/media/webrtc/tests/mochitests/test_peerConnection_basicAudioRelayPolicy.html b/dom/media/webrtc/tests/mochitests/test_peerConnection_basicAudioRelayPolicy.html new file mode 100644 index 0000000000..ced57ff8a3 --- /dev/null +++ b/dom/media/webrtc/tests/mochitests/test_peerConnection_basicAudioRelayPolicy.html @@ -0,0 +1,83 @@ +<!DOCTYPE HTML> +<html> +<head> + <script type="application/javascript" src="pc.js"></script> +</head> +<body> +<pre id="test"> +<script type="application/javascript"> +createHTML({ + bug: "1663746", + title: "Basic tests for relay ice policy" +}); + +runNetworkTest(async () => { + await pushPrefs( + // Enable mDNS, since there are some checks we want to run with that + ['media.peerconnection.ice.obfuscate_host_addresses', true]); + + const offerer = new RTCPeerConnection({iceServers: iceServersArray, iceTransportPolicy: 'relay'}); + const answerer = new RTCPeerConnection({iceServers: iceServersArray}); + + offerer.onicecandidate = e => { + if (e.candidate) { + ok(!e.candidate.candidate.includes(' host '), 'IceTransportPolicy \"relay\" should prevent the advertisement of host candidates'); + ok(!e.candidate.candidate.includes(' srflx '), 'IceTransportPolicy \"relay\" should prevent the advertisement of srflx candidates'); + } + answerer.addIceCandidate(e.candidate); + }; + + answerer.onicecandidate = e => { + if (e.candidate && e.candidate.candidate.includes(' host ')) { + ok(e.candidate.candidate.includes('.local'), 'When obfuscate_host_addresses is true, we expect host candidates to use mDNS'); + } + offerer.addIceCandidate(e.candidate); + }; + + const offererConnected = new Promise(r => { + offerer.oniceconnectionstatechange = () => { + if (offerer.iceConnectionState == 'connected') { + r(); + } + }; + }); + + const answererConnected = new Promise(r => { + answerer.oniceconnectionstatechange = () => { + if (answerer.iceConnectionState == 'connected') { + r(); + } + }; + }); + + const offer = await offerer.createOffer({offerToReceiveAudio: true}); + await Promise.all([offerer.setLocalDescription(offer), answerer.setRemoteDescription(offer)]); + const answer = await answerer.createAnswer(); + await Promise.all([answerer.setLocalDescription(answer), offerer.setRemoteDescription(answer)]); + + info('Waiting for ICE to connect'); + await Promise.all([offererConnected, answererConnected]); + + const offererStats = await offerer.getStats(); + const localCandidates = [...offererStats.values()].filter(stat => stat.type == 'local-candidate'); + const remoteCandidates = [...offererStats.values()].filter(stat => stat.type == 'remote-candidate'); + isnot(localCandidates, []); + isnot(remoteCandidates, []); + + const localNonRelayCandidates = + localCandidates.filter(cand => cand.candidateType != 'relay'); + is(localNonRelayCandidates.length, 0, `There should only be local relay candidates, because we are using the "relay" IceTransportPolicy, but we got ${JSON.stringify(localNonRelayCandidates)}`); + + const remoteHostCandidates = + remoteCandidates.filter(cand => cand.candidateType == 'host'); + is(remoteHostCandidates.length, 0, `There should be no remote host candidates in the stats, because mDNS resolution should have been disabled by the "relay" IceTransportPolicy, but we got ${JSON.stringify(remoteHostCandidates)}`); + + offerer.close(); + answerer.close(); + + await SpecialPowers.popPrefEnv(); +}, { useIceServer: true }); +</script> +</pre> +</body> +</html> |