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
|
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test.js"></script>
</head>
<body>
<script>
description("Test if various kinds of MIDI messages can be validated.");
shouldBeDefined("testRunner.setMIDISysexPermission");
shouldBeDefined("navigator.requestMIDIAccess");
window.jsTestIsAsync = true;
testRunner.setMIDISysexPermission(true);
navigator.requestMIDIAccess({sysex: true}).then(function (a) {
output = a.outputs.values().next().value;
// Note on(off).
output.send([0xff, 0x90, 0x00, 0x00, 0x90, 0x07, 0x00]);
// Running status is not allowed in Web MIDI API.
shouldThrow('output.send([0x00, 0x01])');
// Unexpected End of Sysex.
shouldThrow('output.send([0xf7])');
// Unexpected reserved status bytes.
shouldThrow('output.send([0xf4])');
shouldThrow('output.send([0xf5])');
shouldThrow('output.send([0xf9])');
shouldThrow('output.send([0xfd])');
// Incomplete channel messages.
shouldThrow('output.send([0x80])');
shouldThrow('output.send([0x80, 0x00])');
shouldThrow('output.send([0x90])');
shouldThrow('output.send([0x90, 0x00])');
shouldThrow('output.send([0xa0])');
shouldThrow('output.send([0xa0, 0x00])');
shouldThrow('output.send([0xb0])');
shouldThrow('output.send([0xb0, 0x00])');
shouldThrow('output.send([0xc0])');
shouldThrow('output.send([0xd0])');
shouldThrow('output.send([0xe0])');
shouldThrow('output.send([0xe0, 0x00])');
// Incomplete system messages.
shouldThrow('output.send([0xf1])');
shouldThrow('output.send([0xf2])');
shouldThrow('output.send([0xf2, 0x00])');
shouldThrow('output.send([0xf3])');
// Invalid data bytes.
shouldThrow('output.send([0x80, 0x80, 0x00])');
shouldThrow('output.send([0x80, 0x00, 0x80])');
// 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]);
shouldThrow('output.send([0xf0, 0x80, 0xf7])');
shouldThrow('output.send([0xf0, 0xf0, 0xf7])');
shouldThrow('output.send([0xf0, 0xff, 0xf7, 0xf7])');
// Reserved status bytes.
shouldThrow('output.send([0xf4, 0x80, 0x00, 0x00])');
shouldThrow('output.send([0x80, 0xf4, 0x00, 0x00])');
shouldThrow('output.send([0x80, 0x00, 0xf4, 0x00])');
shouldThrow('output.send([0x80, 0x00, 0x00, 0xf4])');
shouldThrow('output.send([0xf0, 0xff, 0xf4, 0xf7])');
finishJSTest();
}, function () {
testFailed("requestMIDIAccess() return an error.");
});
</script>
</body>
</html>
|