tor-browser

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

setSinkId-with-MediaElementAudioSourceNode.https.html (2120B)


      1 <!doctype html>
      2 <head>
      3 <title>Test HTMLMediaElement.setSinkId() with MediaElementAudioSourceNode</title>
      4 <link rel="help" href="https://webaudio.github.io/web-audio-api/#MediaElementAudioSourceNode">
      5 </head>
      6 <script src=/resources/testharness.js></script>
      7 <script src=/resources/testharnessreport.js></script>
      8 <script src=/resources/testdriver.js></script>
      9 <script src=/resources/testdriver-vendor.js></script>
     10 <script>
     11 "use strict";
     12 /*
     13 MediaElementAudioSourceNode silences HTMLMediaElement output to underlying
     14 devices but setSinkId() should still function as if there were no
     15 MediaElementAudioSourceNode according to
     16 "The HTMLMediaElement MUST behave in an identical fashion after the
     17 MediaElementAudioSourceNode has been created, except that the rendered audio
     18 will no longer be heard directly, but instead will be heard as a consequence
     19 of the MediaElementAudioSourceNode being connected through the routing graph."
     20 */
     21 
     22 let audio;
     23 promise_setup(async () => {
     24  audio = new Audio();
     25  audio.src = "/media/sound_5.oga";
     26  audio.autoplay = true;
     27  audio.loop = true;
     28  new AudioContext().createMediaElementSource(audio);
     29  await new Promise(r => audio.onplay = r);
     30 });
     31 
     32 promise_test(t => audio.setSinkId(""), "setSinkId on default audio output should always work");
     33 
     34 promise_test(t => promise_rejects_dom(t, "NotFoundError", audio.setSinkId("nonexistent_device_id")),
     35  "setSinkId fails with NotFoundError on made up deviceid");
     36 
     37 promise_test(async t => {
     38  await test_driver.bless('transient activation for selectAudioOutput()');
     39  const {deviceId} = await navigator.mediaDevices.selectAudioOutput();
     40  assert_greater_than(deviceId.length, 0, "deviceId.length");
     41  const p1 = audio.setSinkId(deviceId);
     42  assert_equals(audio.sinkId, "", "before it resolves, setSinkId is unchanged");
     43  await p1;
     44  assert_equals(audio.sinkId, deviceId, "setSinkId updates sinkId to the requested deviceId");
     45  await audio.setSinkId("");
     46  assert_equals(audio.sinkId, "", "resetting sink ID to default audio output should always work");
     47 }, "setSinkId() with output device ID exposed by selectAudioOutput() should resolve");
     48 
     49 </script>