4 <title>WebMIDI Send Test
</title>
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
7 <script type=
"application/javascript" src=
"MIDITestUtils.js"></script>
10 <body onload=
"runTests()">
11 <script class=
"testbody" type=
"application/javascript">
12 SimpleTest.waitForExplicitFinish();
14 async function runTests() {
15 await MIDITestUtils.permissionSetup(true);
16 const access = await navigator.requestMIDIAccess({ sysex: true });
17 const output = access.outputs.get(await MIDITestUtils.stateTestOutputInfo.id);
21 output.send([
0xff,
0x90,
0x00,
0x00,
0x90,
0x07,
0x00]);
24 output.send([
0x00,
0x01])
26 ok(true,
"Caught exception");
29 // Running status is not allowed in Web MIDI API.
30 SimpleTest.doesThrow(() =
> output.send([
0x00,
0x01]),
"Running status is not allowed in Web MIDI API.");
32 // Unexpected End of Sysex.
33 SimpleTest.doesThrow(() =
> output.send([
0xf7]),
"Unexpected End of Sysex.");
35 // Unexpected reserved status bytes.
36 SimpleTest.doesThrow(() =
> output.send([
0xf4]),
"Unexpected reserved status byte 0xf4.");
37 SimpleTest.doesThrow(() =
> output.send([
0xf5]),
"Unexpected reserved status byte 0xf5.");
38 SimpleTest.doesThrow(() =
> output.send([
0xf9]),
"Unexpected reserved status byte 0xf9.");
39 SimpleTest.doesThrow(() =
> output.send([
0xfd]),
"Unexpected reserved status byte 0xfd.");
41 // Incomplete channel messages.
42 SimpleTest.doesThrow(() =
> output.send([
0x80]),
"Incomplete channel message.");
43 SimpleTest.doesThrow(() =
> output.send([
0x80,
0x00]),
"Incomplete channel message.");
44 SimpleTest.doesThrow(() =
> output.send([
0x90]),
"Incomplete channel message.");
45 SimpleTest.doesThrow(() =
> output.send([
0x90,
0x00]),
"Incomplete channel message.");
46 SimpleTest.doesThrow(() =
> output.send([
0xa0]),
"Incomplete channel message.");
47 SimpleTest.doesThrow(() =
> output.send([
0xa0,
0x00]),
"Incomplete channel message.");
48 SimpleTest.doesThrow(() =
> output.send([
0xb0]),
"Incomplete channel message.");
49 SimpleTest.doesThrow(() =
> output.send([
0xb0,
0x00]),
"Incomplete channel message.");
50 SimpleTest.doesThrow(() =
> output.send([
0xc0]),
"Incomplete channel message.");
51 SimpleTest.doesThrow(() =
> output.send([
0xd0]),
"Incomplete channel message.");
52 SimpleTest.doesThrow(() =
> output.send([
0xe0]),
"Incomplete channel message.");
53 SimpleTest.doesThrow(() =
> output.send([
0xe0,
0x00]),
"Incomplete channel message.");
55 // Incomplete system messages.
56 SimpleTest.doesThrow(() =
> output.send([
0xf1]),
"Incomplete system message.");
57 SimpleTest.doesThrow(() =
> output.send([
0xf2]),
"Incomplete system message.");
58 SimpleTest.doesThrow(() =
> output.send([
0xf2,
0x00]),
"Incomplete system message.");
59 SimpleTest.doesThrow(() =
> output.send([
0xf3]),
"Incomplete system message.");
61 // Invalid data bytes.
62 SimpleTest.doesThrow(() =
> output.send([
0x80,
0x80,
0x00]),
"Incomplete system message.");
63 SimpleTest.doesThrow(() =
> output.send([
0x80,
0x00,
0x80]),
"Incomplete system message.");
66 output.send([
0x80,
0x00,
0x00]);
67 output.send([
0x90,
0x00,
0x00]);
68 output.send([
0xa0,
0x00,
0x00]);
69 output.send([
0xb0,
0x00,
0x00]);
70 output.send([
0xc0,
0x00]);
71 output.send([
0xd0,
0x00]);
72 output.send([
0xe0,
0x00,
0x00]);
74 // Real-Time messages.
82 // Valid messages with Real-Time messages.
83 output.send([
0x90,
0xff,
0xff,
0x00,
0xff,
0x01,
0xff,
0x80,
0xff,
0x00,
84 0xff,
0xff,
0x00,
0xff,
0xff]);
87 output.send([
0xf0,
0x00,
0x01,
0x02,
0x03,
0xf7]);
88 output.send([
0xf0,
0xf8,
0xf7,
0xff]);
89 SimpleTest.doesThrow(() =
> output.send([
0xf0,
0x80,
0xf7]),
"Invalid sysex message.");
90 SimpleTest.doesThrow(() =
> output.send([
0xf0,
0xf0,
0xf7]),
"Double begin sysex message.");
91 SimpleTest.doesThrow(() =
> output.send([
0xf0,
0xff,
0xf7,
0xf7]),
"Double end sysex message.");
93 // Reserved status bytes.
94 SimpleTest.doesThrow(() =
> output.send([
0xf4,
0x80,
0x00,
0x00]),
"Reserved status byte.");
95 SimpleTest.doesThrow(() =
> output.send([
0x80,
0xf4,
0x00,
0x00]),
"Reserved status byte.");
96 SimpleTest.doesThrow(() =
> output.send([
0x80,
0x00,
0xf4,
0x00]),
"Reserved status byte.");
97 SimpleTest.doesThrow(() =
> output.send([
0x80,
0x00,
0x00,
0xf4]),
"Reserved status byte.");
98 SimpleTest.doesThrow(() =
> output.send([
0xf0,
0xff,
0xf4,
0xf7]),
"Reserved status byte.");
100 // Invalid timestamps.
101 SimpleTest.doesThrow(() =
> output.send([], NaN),
"NaN timestamp.");
102 SimpleTest.doesThrow(() =
> output.send([], Infinity),
"Infinity timestamp.");
103 SimpleTest.doesThrow(() =
> output.send(new Uint8Array(), NaN),
"NaN timestamp.");
104 SimpleTest.doesThrow(() =
> output.send(new Uint8Array(), Infinity),
"Infinity timestamp.");