| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../resources/js-test.js"></script> |
| 5 <script src="../http/tests/resources/permissions-helper.js"></script> |
| 6 </head> |
| 7 <body> |
| 8 <script> |
| 9 |
| 10 description("Test if various kinds of system messages can be validated."); |
| 11 |
| 12 window.jsTestIsAsync = true; |
| 13 |
| 14 // See https://www.midi.org/specifications/item/table-1-summary-of-midi-message |
| 15 let systemMessages = (function(messages) { |
| 16 // Prepare various combinations of messages from input message array. |
| 17 let combinations = []; |
| 18 for (let i = 0; i < messages.length; ++i) { |
| 19 combinations.push(messages[i]); |
| 20 for (let j = 0; j < messages.length; ++j) { |
| 21 combinations.push(messages[i].concat(messages[j])); |
| 22 for (let k = 0; k < messages.length; ++k) { |
| 23 combinations.push(messages[i].concat(messages[j], messages[k])); |
| 24 } |
| 25 } |
| 26 } |
| 27 return combinations; |
| 28 })([[0xf1, 0x00], |
| 29 [0xf2, 0x00, 0x00], |
| 30 [0xf3, 0x00], |
| 31 [0xf6]]); |
| 32 |
| 33 let reservedSystemMessages = [[0xf4], [0xf5]]; |
| 34 let systemExclusiveMessages = [[0xf0, 0xf7], [0xf0, 0x00, 0xf7]]; |
| 35 |
| 36 PermissionsHelper.setPermission("midi", "granted").then(() => { |
| 37 return navigator.requestMIDIAccess(); |
| 38 }).then(a => { |
| 39 output = a.outputs.values().next().value; |
| 40 |
| 41 for (let message of systemMessages) { |
| 42 output.send(message); |
| 43 testPassed("output.send([" + message + "])"); |
| 44 } |
| 45 |
| 46 for (message of reservedSystemMessages) { |
| 47 shouldThrow("output.send(message)"); |
| 48 } |
| 49 |
| 50 for (message of systemExclusiveMessages) { |
| 51 shouldThrow("output.send(message)"); |
| 52 } |
| 53 |
| 54 finishJSTest(); |
| 55 }).catch(e => { |
| 56 testFailed(e.toString()); |
| 57 finishJSTest(); |
| 58 }); |
| 59 |
| 60 </script> |
| 61 </body> |
| 62 </html> |
| OLD | NEW |