DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (b6d82b1a6b02)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
<!DOCTYPE HTML>
<html>
<head>
  <script type="application/javascript" src="mediaStreamPlayback.js"></script>
</head>
<body>
<pre id="test">

<audio id="audio"></audio>

<script>
  createHTML({
    title: "SetSinkId in HTMLMediaElement",
    bug: "934425",
  });

  /**
   * Run a test to verify set sink id in audio element.
   */
  runTest(async () => {
    await pushPrefs(["media.setsinkid.enabled", true]);

    if (!SpecialPowers.getCharPref("media.audio_loopback_dev", "")) {
      ok(false, "No loopback device set by framework. Try --use-test-media-devices");
      return;
    }

    const allDevices = await navigator.mediaDevices.enumerateDevices();
    const audioDevices = allDevices.filter(({kind}) => kind == 'audiooutput');
    info(`Found  ${audioDevices.length} output devices`);
    ok(audioDevices.length > 0, "More than one output device found");

    // Have to do this to access normally-preffed off binding methods for some
    // reason.
    // See bug 1544257.
    audio = SpecialPowers.wrap(audio);

    is(audio.sinkId, "", "Initial value is empty string");

    const p = audio.setSinkId(audioDevices[0].deviceId);
    is(audio.sinkId, "", "Value is unchanged upon function return");
    is(await p, undefined, "promise resolves with undefined");
    is(audio.sinkId, audioDevices[0].deviceId, `Sink device is set, id: ${audio.sinkId}`);

    await audio.setSinkId(audioDevices[0].deviceId);
    ok(true, `Sink device is set for 2nd time for the same id: ${audio.sinkId}`);

    try {
      await audio.setSinkId("dummy sink id");
      ok(false, "Never enter here, this must fail");
    } catch (error) {
      ok(true, `Set sink id expected to fail: ${error}`);
      is(error.name, "NotFoundError", "Verify correct error");
    }
  });

</script>
</pre>
</body>
</html>