blob: ccce32fc6a5ff3d9e90b85f4bec038ccec0880da [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="../http/tests/resources/permissions-helper.js"></script>
<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="file:///gen/media/midi/midi_service.mojom.js"></script>
<script src="../http/tests/webmidi/mock-midiservice.js"></script>
</head>
<body>
<script>
description("Test if various kinds of system messages can be validated.");
window.jsTestIsAsync = true;
// See https://www.midi.org/specifications/item/table-1-summary-of-midi-message
let systemMessages = (function(messages) {
// Prepare various combinations of messages from input message array.
let combinations = [];
for (let i = 0; i < messages.length; ++i) {
combinations.push(messages[i]);
for (let j = 0; j < messages.length; ++j) {
combinations.push(messages[i].concat(messages[j]));
for (let k = 0; k < messages.length; ++k) {
combinations.push(messages[i].concat(messages[j], messages[k]));
}
}
}
return combinations;
})([[0xf1, 0x00],
[0xf2, 0x00, 0x00],
[0xf3, 0x00],
[0xf6]]);
let reservedSystemMessages = [[0xf4], [0xf5]];
let systemExclusiveMessages = [[0xf0, 0xf7], [0xf0, 0x00, 0xf7]];
PermissionsHelper.setPermission("midi", "granted").then(() => {
return navigator.requestMIDIAccess();
}).then(a => {
output = a.outputs.values().next().value;
for (let message of systemMessages) {
output.send(message);
testPassed("output.send([" + message + "])");
}
for (message of reservedSystemMessages) {
shouldThrow("output.send(message)");
}
for (message of systemExclusiveMessages) {
shouldThrow("output.send(message)");
}
finishJSTest();
}).catch(e => {
testFailed(e.toString());
finishJSTest();
});
</script>
</body>
</html>