tor-browser

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

idlharness.https.window.js (1304B)


      1 // META: script=/resources/WebIDLParser.js
      2 // META: script=/resources/idlharness.js
      3 // META: script=/resources/testdriver.js
      4 // META: script=/resources/testdriver-vendor.js
      5 // META: timeout=long
      6 
      7 // https://webaudio.github.io/web-midi-api/
      8 
      9 'use strict';
     10 
     11 idl_test(
     12  ['webmidi'],
     13  ['html', 'dom', 'permissions'],
     14  async idl_array => {
     15    idl_array.add_objects({
     16      MIDIPort: [],
     17      MIDIMessageEvent: [
     18        'new MIDIMessageEvent("type", { data: new Uint8Array([0]) })'
     19      ],
     20      MIDIConnectionEvent: ['new MIDIConnectionEvent("type")'],
     21    })
     22 
     23    // Chromium requires the sysex permission to allow any type of MIDI
     24    await test_driver.set_permission({name: 'midi', sysex: true}, 'granted');
     25 
     26    self.access = await navigator.requestMIDIAccess();
     27    self.inputs = access.inputs;
     28    self.outputs = access.outputs;
     29    idl_array.add_objects({ MIDIInputMap: ['inputs'] });
     30    idl_array.add_objects({ MIDIOutputMap: ['outputs'] });
     31    idl_array.add_objects({ MIDIAccess: ['access'] });
     32    if (inputs.size) {
     33      self.input = Array.from(access.inputs.values())[0];
     34      idl_array.add_objects({ MIDIInput: ['input'] });
     35    }
     36    if (outputs.size) {
     37      self.output = Array.from(access.outputs.values())[0];
     38      idl_array.add_objects({ MIDIOutput: ['output'] });
     39    }
     40  }
     41 );