Commit 0b893198 authored by Nico Grunbaum's avatar Nico Grunbaum
Browse files

Bug 1439041 - tighten up RTP sources mochitests r=mjf

MozReview-Commit-ID: 6fzHZpe1U0w

--HG--
extra : rebase_source : a5f5436efc1c12b0693814b5397d4777b4cd9dbc
parent 3e806026
Loading
Loading
Loading
Loading
+22 −8
Original line number Diff line number Diff line
@@ -29,16 +29,20 @@
    await waitForSyncSources(test);
    let receivers = [...test.pcRemote.getReceivers(),
                     ...test.pcLocal.getReceivers()];
    is(receivers.length, 2,
       `Expected number of receivers is 2. (${receivers.length})`);
    for (let recv of receivers) {
      let syncSources = recv.getSynchronizationSources();
      ok(syncSources,
         "Receiver has Synchronization sources " + JSON.stringify(syncSources));
      is(syncSources.length, 1, "Each receiver has only a single sync source");
      let source = recv.getSynchronizationSources()[0];
      ok(source.audioLevel,
      ok(source.audioLevel !== null,
         `Synchronization source has audio level. (${source.audioLevel})`);
      ok(source.audioLevel < 128,
         `Synchronization source audio level < 128. (${source.audioLevel})`);
      ok(source.audioLevel >= 0.0,
         `Synchronization source audio level >= 0.0 (${source.audioLevel})`);
      ok(source.audioLevel <= 1.0,
         `Synchronization source audio level <= 1.0 (${source.audioLevel})`);
      ok(source.timestamp,
         `Synchronization source has timestamp (${source.timestamp})`);
      ok(window.performance.now() + window.performance.timeOrigin -
@@ -54,12 +58,22 @@
    await waitForSyncSources(test);
    let receivers = [...test.pcRemote.getReceivers(),
                     ...test.pcLocal.getReceivers()];
    is(receivers.length, 2, "Expected number of receivers");
    is(receivers.length, 2,
       `Expected number of receivers is 2. (${receivers.length})`);
    let sourceSets = [[],[]];
    for (let sourceSet of sourceSets) {
      for (let recv of receivers) {
      is(JSON.stringify(recv.getSynchronizationSources()),
         JSON.stringify(recv.getSynchronizationSources()),
         "Subsequent getSynchronizationSources calls are cached.");
        let sources = recv.getSynchronizationSources();
        ok(sources.length, 1,
           `Expected number of sources is 1. (${sources.length})`);
        sourceSet.push(sources);
      }
      // Busy wait 1s before trying again
      let endTime = performance.now() + 1000;
      while (performance.now() < endTime) {};
    }
    is(JSON.stringify(sourceSets[0]), JSON.stringify(sourceSets[1]),
       "Subsequent getSynchronizationSources calls are cached.");
  };

  var test;