summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webmidi/idlharness.https.window.js
blob: 1474b3845af1ddd8d03f58ffc1cfdad9dc049328 (plain)
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
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
// META: timeout=long

// https://webaudio.github.io/web-midi-api/

'use strict';

idl_test(
  ['webmidi'],
  ['html', 'dom', 'permissions'],
  async idl_array => {
    idl_array.add_objects({
      MIDIAccess: ['access'],
      MIDIInputMap: ['inputs'],
      MIDIOutputMap: ['outputs'],
      MIDIConnectionEvent: ['new MIDIConnectionEvent("type")'],
    })

    self.access = await navigator.requestMIDIAccess();
    self.inputs = access.inputs;
    if (inputs.size) {
      self.input = Array.from(access.inputs.values())[0];
      idl_array.add_objects({ MIDIInput: ['input'] });
    }
    self.outputs = access.outputs;
    if (outputs.size) {
      self.output = Array.from(access.outputs.values())[0];
      idl_array.add_objects({ MIDIOutput: ['output'] });
    }
  }
);