tor-browser

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

test_getUserMedia_cubebDisabledFakeStreams.html (1341B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <script type="application/javascript" src="mediaStreamPlayback.js"></script>
      5 </head>
      6 <body>
      7 <pre id="test">
      8 <script type="application/javascript">
      9  createHTML({
     10    title: "getUserMedia fake stream with Cubeb Disabled Test",
     11    bug: "1443525"
     12  });
     13  /**
     14   * Run a test to verify we can still return a fake stream even if we cannot
     15   * get a cubeb context. See also Bug 1434477
     16   */
     17  runTest(async function () {
     18    info("Get user media with cubeb disabled and fake tracks starting");
     19    // Push prefs to ensure no cubeb context and fake streams
     20    await pushPrefs(["media.cubeb.force_null_context", true],
     21                    ["media.navigator.streams.fake", true],
     22                    ['media.audio_loopback_dev', '']);
     23    let testAudio = createMediaElement('audio', 'testAudio');
     24    // Request audio only, to avoid cams
     25    let constraints = {audio: true, video: false};
     26    let stream;
     27    try {
     28      stream = await getUserMedia(constraints);
     29    } catch (e) {
     30      // We've got no audio backend, so we expect gUM to fail
     31      ok(false, `Did not expect to fail, but got ${e}`);
     32      return;
     33    }
     34    ok(stream, "getUserMedia should get a stream!");
     35    let playback = new MediaStreamPlayback(testAudio, stream);
     36    await playback.playMedia(false);
     37  });
     38 
     39 
     40 </script>
     41 </pre>
     42 </body>
     43 </html>