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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
<html>
<head>
<title>WebMIDI Send Test</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="application/javascript" src="MIDITestUtils.js"></script>
</head>
<body onload="runTests()">
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
async function runTests() {
await MIDITestUtils.permissionSetup(true);
const access = await navigator.requestMIDIAccess({ sysex: true });
const output = access.outputs.get(await MIDITestUtils.stateTestOutputInfo.id);
// Note on(off).
output.send([0xff, 0x90, 0x00, 0x00, 0x90, 0x07, 0x00]);
try {
output.send([0x00, 0x01])
} catch (ex) {
ok(true, "Caught exception");
}
// Running status is not allowed in Web MIDI API.
SimpleTest.doesThrow(() => output.send([0x00, 0x01]), "Running status is not allowed in Web MIDI API.");
// Unexpected End of Sysex.
SimpleTest.doesThrow(() => output.send([0xf7]), "Unexpected End of Sysex.");
// Unexpected reserved status bytes.
SimpleTest.doesThrow(() => output.send([0xf4]), "Unexpected reserved status byte 0xf4.");
SimpleTest.doesThrow(() => output.send([0xf5]), "Unexpected reserved status byte 0xf5.");
SimpleTest.doesThrow(() => output.send([0xf9]), "Unexpected reserved status byte 0xf9.");
SimpleTest.doesThrow(() => output.send([0xfd]), "Unexpected reserved status byte 0xfd.");
// Incomplete channel messages.
SimpleTest.doesThrow(() => output.send([0x80]), "Incomplete channel message.");
SimpleTest.doesThrow(() => output.send([0x80, 0x00]), "Incomplete channel message.");
SimpleTest.doesThrow(() => output.send([0x90]), "Incomplete channel message.");
SimpleTest.doesThrow(() => output.send([0x90, 0x00]), "Incomplete channel message.");
SimpleTest.doesThrow(() => output.send([0xa0]), "Incomplete channel message.");
SimpleTest.doesThrow(() => output.send([0xa0, 0x00]), "Incomplete channel message.");
SimpleTest.doesThrow(() => output.send([0xb0]), "Incomplete channel message.");
SimpleTest.doesThrow(() => output.send([0xb0, 0x00]), "Incomplete channel message.");
SimpleTest.doesThrow(() => output.send([0xc0]), "Incomplete channel message.");
SimpleTest.doesThrow(() => output.send([0xd0]), "Incomplete channel message.");
SimpleTest.doesThrow(() => output.send([0xe0]), "Incomplete channel message.");
SimpleTest.doesThrow(() => output.send([0xe0, 0x00]), "Incomplete channel message.");
// Incomplete system messages.
SimpleTest.doesThrow(() => output.send([0xf1]), "Incomplete system message.");
SimpleTest.doesThrow(() => output.send([0xf2]), "Incomplete system message.");
SimpleTest.doesThrow(() => output.send([0xf2, 0x00]), "Incomplete system message.");
SimpleTest.doesThrow(() => output.send([0xf3]), "Incomplete system message.");
// Invalid data bytes.
SimpleTest.doesThrow(() => output.send([0x80, 0x80, 0x00]), "Incomplete system message.");
SimpleTest.doesThrow(() => output.send([0x80, 0x00, 0x80]), "Incomplete system message.");
// Complete messages.
output.send([0x80, 0x00, 0x00]);
output.send([0x90, 0x00, 0x00]);
output.send([0xa0, 0x00, 0x00]);
output.send([0xb0, 0x00, 0x00]);
output.send([0xc0, 0x00]);
output.send([0xd0, 0x00]);
output.send([0xe0, 0x00, 0x00]);
// Real-Time messages.
output.send([0xf8]);
output.send([0xfa]);
output.send([0xfb]);
output.send([0xfc]);
output.send([0xfe]);
output.send([0xff]);
// Valid messages with Real-Time messages.
output.send([0x90, 0xff, 0xff, 0x00, 0xff, 0x01, 0xff, 0x80, 0xff, 0x00,
0xff, 0xff, 0x00, 0xff, 0xff]);
// Sysex messages.
output.send([0xf0, 0x00, 0x01, 0x02, 0x03, 0xf7]);
output.send([0xf0, 0xf8, 0xf7, 0xff]);
SimpleTest.doesThrow(() => output.send([0xf0, 0x80, 0xf7]), "Invalid sysex message.");
SimpleTest.doesThrow(() => output.send([0xf0, 0xf0, 0xf7]), "Double begin sysex message.");
SimpleTest.doesThrow(() => output.send([0xf0, 0xff, 0xf7, 0xf7]), "Double end sysex message.");
// Reserved status bytes.
SimpleTest.doesThrow(() => output.send([0xf4, 0x80, 0x00, 0x00]), "Reserved status byte.");
SimpleTest.doesThrow(() => output.send([0x80, 0xf4, 0x00, 0x00]), "Reserved status byte.");
SimpleTest.doesThrow(() => output.send([0x80, 0x00, 0xf4, 0x00]), "Reserved status byte.");
SimpleTest.doesThrow(() => output.send([0x80, 0x00, 0x00, 0xf4]), "Reserved status byte.");
SimpleTest.doesThrow(() => output.send([0xf0, 0xff, 0xf4, 0xf7]), "Reserved status byte.");
// Invalid timestamps.
SimpleTest.doesThrow(() => output.send([], NaN), "NaN timestamp.");
SimpleTest.doesThrow(() => output.send([], Infinity), "Infinity timestamp.");
SimpleTest.doesThrow(() => output.send(new Uint8Array(), NaN), "NaN timestamp.");
SimpleTest.doesThrow(() => output.send(new Uint8Array(), Infinity), "Infinity timestamp.");
SimpleTest.finish();
}
</script>
</body>
</html>
|