tor-browser

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

idlharness.https.window.js (1457B)


      1 // META: script=/resources/WebIDLParser.js
      2 // META: script=/resources/idlharness.js
      3 // META: timeout=long
      4 
      5 'use strict';
      6 
      7 // https://w3c.github.io/mediacapture-main/
      8 
      9 idl_test(
     10  ['mediacapture-streams'],
     11  ['webidl', 'dom', 'html', 'permissions'],
     12  async idl_array => {
     13    const inputDevices = [];
     14    const outputDevices = [];
     15    try {
     16      const list = await navigator.mediaDevices.enumerateDevices();
     17      for (const device of list) {
     18        if (device.kind in self) {
     19          continue;
     20        }
     21        assert_in_array(device.kind, ['audioinput', 'videoinput', 'audiooutput']);
     22        self[device.kind] = device;
     23        if (device.kind.endsWith('input')) {
     24          inputDevices.push(device.kind);
     25        } else {
     26          outputDevices.push(device.kind);
     27        }
     28      }
     29    } catch (e) {}
     30 
     31    try {
     32      self.stream = await navigator.mediaDevices.getUserMedia({audio: true});
     33      self.track = stream.getTracks()[0];
     34      self.trackEvent = new MediaStreamTrackEvent("type", {
     35        track: track,
     36      });
     37    } catch (e) {}
     38 
     39    idl_array.add_objects({
     40      InputDeviceInfo: inputDevices,
     41      MediaStream: ['stream', 'new MediaStream()'],
     42      Navigator: ['navigator'],
     43      MediaDevices: ['navigator.mediaDevices'],
     44      MediaDeviceInfo: outputDevices,
     45      MediaStreamTrack: ['track'],
     46      MediaStreamTrackEvent: ['trackEvent'],
     47      OverconstrainedError: ['new OverconstrainedError("constraint")'],
     48    });
     49  }
     50 );