tor-browser

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

test_peerConnection_audioSynchronizationSourcesUnidirectional.html (1875B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <script type="application/javascript" src="pc.js"></script>
      5 </head>
      6 <body>
      7 <pre id="test">
      8 <script type="application/javascript">
      9  createHTML({
     10    bug: "1439001",
     11    title: "Test audio unidirectional getSynchronizationSources"
     12  });
     13 
     14  var waitForSyncSources = async (test) => {
     15    let receiver = test.pcRemote.getReceivers()[0];
     16    ok(receiver, "Remote has a receiver");
     17    // Wait for remote sync source
     18    while (!receiver.getSynchronizationSources().length) {
     19      await wait(250);
     20    }
     21    is(receiver.getSynchronizationSources().length, 1,
     22       "Remote receiver has a synchronization source");
     23    // Make sure local has no sync source
     24    is(test.pcLocal.getReceivers()[0].getSynchronizationSources().length, 0,
     25       "Local receiver has no synchronization source");
     26  };
     27  /*
     28   * Test to make sure that in unidirectional calls, the receiving end has
     29   * synchronization sources with audio levels, and the sending end has none.
     30   */
     31  var testGetSynchronizationSourcesUnidirectional = async (test) => {
     32    await waitForSyncSources(test);
     33    let receiver = test.pcRemote.getReceivers()[0];
     34    let syncSources = receiver.getSynchronizationSources();
     35    ok(syncSources.length,
     36       "Receiver has Synchronization sources " + JSON.stringify(syncSources));
     37    is(syncSources.length, 1, "Receiver has only a single sync source");
     38    let syncSource = syncSources[0];
     39    ok(syncSource.audioLevel !== undefined, "SynchronizationSource has audioLevel");
     40  };
     41 
     42  var test;
     43  runNetworkTest(function(options) {
     44    test = new PeerConnectionTest(options);
     45    test.chain.insertAfter("PC_REMOTE_WAIT_FOR_MEDIA_FLOW",
     46      [testGetSynchronizationSourcesUnidirectional]);
     47    test.setMediaConstraints([{audio: true}], []);
     48    test.pcLocal.audioElementsOnly = true;
     49    return test.run();
     50  });
     51 </script>
     52 </pre>
     53 </body>
     54 </html>