tor-browser

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

test_peerConnection_basicAudioNATRelayWithStun300.html (2379B)


      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: "857668",
     12  title: "Basic audio-only peer connection with port dependent NAT, for verifying UDP relay with STUN 300 responses"
     13 });
     14 
     15 // This test uses the NAT simulator, which doesn't work in https, so we turn
     16 // on getUserMedia in http, which requires a reload.
     17 if (!("mediaDevices" in navigator)) {
     18  SpecialPowers.pushPrefEnv({set: [['media.devices.insecure.enabled', true]]},
     19                            () => location.reload());
     20 } else {
     21  runNetworkTest(async (options = {}) => {
     22    await pushPrefs(
     23        ['media.peerconnection.ice.obfuscate_host_addresses', false],
     24        ['media.peerconnection.nat_simulator.filtering_type', 'PORT_DEPENDENT'],
     25        ['media.peerconnection.nat_simulator.mapping_type', 'PORT_DEPENDENT'],
     26        ['media.peerconnection.nat_simulator.block_tcp', true],
     27        ['media.peerconnection.nat_simulator.block_tls', true],
     28        ['media.peerconnection.ice.loopback', true],
     29        ['media.getusermedia.insecure.enabled', true]);
     30    options.expectedLocalCandidateType = "srflx";
     31    options.expectedRemoteCandidateType = "relay";
     32    const turnServer = iceServersArray.find(server => "username" in server);
     33    const turnRedirectPort = turnServer.turn_redirect_port;
     34    const turnHostname = getTurnHostname(turnServer.urls[0]);
     35    turnServer.urls = [`turn:${turnHostname}:${turnRedirectPort}`];
     36    // Override turn servers so we can test redirects
     37    options.config_remote = {iceServers: [turnServer]};
     38    // If both have TURN, it is a toss-up which one will end up using a
     39    // relay, so we disable TURN for one side.
     40    options.turn_disabled_local = true;
     41    const test = new PeerConnectionTest(options);
     42    // Make sure we don't end up choosing the wrong thing due to delays in
     43    // trickle. Once we are willing to accept trickle after ICE success, we
     44    // can maybe wait a bit to allow things to stabilize.
     45    // TODO(bug 1238249)
     46    makeOffererNonTrickle(test.chain);
     47    makeAnswererNonTrickle(test.chain);
     48    test.setMediaConstraints([{audio: true}], [{audio: true}]);
     49    await test.run();
     50  }, { useIceServer: true });
     51 }
     52 </script>
     53 </pre>
     54 </body>
     55 </html>