3 <title>WebMIDI Listener Test
</title>
4 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
5 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
6 <script type=
"application/javascript" src=
"MIDITestUtils.js"></script>
9 <body onload=
"runTests()">
10 <script class=
"testbody" type=
"application/javascript">
11 SimpleTest.waitForExplicitFinish();
13 let objectCompare = async (type, props, obj) =
> {
14 for (var prop in props) {
15 is(await props[prop], obj[prop], type +
" property value " + prop +
" is " + props[prop]);
18 let failOnCall = () =
> {
19 ok(false,
"No connect/state events should be received on startup!");
21 async function runTests () {
22 await MIDITestUtils.permissionSetup(true);
23 // Request access without sysex.
24 let access = await navigator.requestMIDIAccess({
"sysex": false });
25 ok(true,
"MIDI Access Request successful");
26 is(access.sysexEnabled, false,
"Sysex should be false");
27 access.addEventListener(
"statechange", failOnCall);
28 var input_id = await MIDITestUtils.inputInfo.id;
29 var output_id = await MIDITestUtils.outputInfo.id;
30 var inputs = access.inputs;
31 var outputs = access.outputs;
32 is(inputs.size,
1,
"Should have one input");
33 is(outputs.size,
3,
"Should have three outputs");
34 ok(inputs.has(input_id),
"input list should contain input id");
35 ok(outputs.has(output_id),
"output list should contain output id");
36 var input = access.inputs.get(input_id);
37 var output = access.outputs.get(output_id);
38 await objectCompare(
"input", MIDITestUtils.inputInfo, input);
39 await objectCompare(
"output", MIDITestUtils.outputInfo, output);
40 access.removeEventListener(
"statechange", failOnCall);