tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

getStats-remote-candidate-ufrag.html (1895B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>Exposure of remote candidate ufrag on stats</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script src="../webrtc/RTCPeerConnection-helper.js"></script>
      7 <script>
      8 promise_test(async (test) => {
      9    const localPc = new RTCPeerConnection();
     10    test.add_cleanup(() => localPc.close());
     11    const remotePc = new RTCPeerConnection();
     12    test.add_cleanup(() => remotePc.close());
     13 
     14    const localDataChannel = localPc.createDataChannel('test');
     15    localPc.addEventListener('icecandidate', event => {
     16        remotePc.addIceCandidate(event.candidate);
     17    });
     18    await localPc.setLocalDescription();
     19    await remotePc.setRemoteDescription(localPc.localDescription);
     20    const answer = await remotePc.createAnswer();
     21    await remotePc.setLocalDescription(answer);
     22 
     23    await waitForIceStateChange(remotePc, ['connected', 'completed']);
     24 
     25    const remoteCandidateStats = [...(await localPc.getStats()).values()].find(({type}) => type === 'remote-candidate');
     26    assert_equals(remoteCandidateStats.candidateType, 'prflx', 'candidateType should be `prflx`');
     27    assert_equals(remoteCandidateStats.usernameFragment, undefined, 'usernameFragment should be undefined');
     28 
     29    await localPc.setRemoteDescription(answer);
     30    await new Promise(r => test.step_timeout(r, 100));
     31 
     32    const remoteCandidateStats2 = [...(await localPc.getStats()).values()].find(({type}) => type === 'remote-candidate');
     33    // candidateType is still prflx since the candidate was not signaled.
     34    assert_equals(remoteCandidateStats.candidateType, 'prflx', 'candidateType should be `prflx`');
     35    assert_not_equals(remoteCandidateStats2.usernameFragment, undefined, 'usernameFragment should not be undefined after signaling');
     36 }, 'Do not expose in stats remote ufrags that are not known via signaling');
     37 </script>