OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../resources/js-test.js"></script> | 4 <script src="../resources/js-test.js"></script> |
| 5 <script src="../resources/permissions-helper.js"></script> |
5 </head> | 6 </head> |
6 <body> | 7 <body> |
7 <script> | 8 <script> |
8 | 9 |
9 description("Test if various kinds of MIDI messages can be validated."); | 10 description("Test if various kinds of MIDI messages can be validated."); |
10 | 11 |
11 shouldBeDefined("testRunner.setPermission"); | 12 shouldBeDefined("testRunner.setPermission"); |
12 shouldBeDefined("navigator.requestMIDIAccess"); | 13 shouldBeDefined("navigator.requestMIDIAccess"); |
13 | 14 |
14 window.jsTestIsAsync = true; | 15 window.jsTestIsAsync = true; |
15 | 16 |
16 testRunner.setPermission('midi-sysex', 'granted', location.origin, location.orig
in); | 17 PermissionsHelper.setPermission('midi-sysex', 'granted').then(function() { |
17 | 18 return navigator.requestMIDIAccess({sysex: true}); |
18 navigator.requestMIDIAccess({sysex: true}).then(function (a) { | 19 }).then(function(a) { |
19 output = a.outputs.values().next().value; | 20 output = a.outputs.values().next().value; |
20 | 21 |
21 // Note on(off). | 22 // Note on(off). |
22 output.send([0xff, 0x90, 0x00, 0x00, 0x90, 0x07, 0x00]); | 23 output.send([0xff, 0x90, 0x00, 0x00, 0x90, 0x07, 0x00]); |
23 | 24 |
24 // Running status is not allowed in Web MIDI API. | 25 // Running status is not allowed in Web MIDI API. |
25 shouldThrow('output.send([0x00, 0x01])'); | 26 shouldThrow('output.send([0x00, 0x01])'); |
26 | 27 |
27 // Unexpected End of Sysex. | 28 // Unexpected End of Sysex. |
28 shouldThrow('output.send([0xf7])'); | 29 shouldThrow('output.send([0xf7])'); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 shouldThrow('output.send([0x80, 0x00, 0x00, 0xf4])'); | 92 shouldThrow('output.send([0x80, 0x00, 0x00, 0xf4])'); |
92 shouldThrow('output.send([0xf0, 0xff, 0xf4, 0xf7])'); | 93 shouldThrow('output.send([0xf0, 0xff, 0xf4, 0xf7])'); |
93 | 94 |
94 // Invalid timestamps. | 95 // Invalid timestamps. |
95 shouldThrow('output.send([], NaN)'); | 96 shouldThrow('output.send([], NaN)'); |
96 shouldThrow('output.send([], Infinity)'); | 97 shouldThrow('output.send([], Infinity)'); |
97 shouldThrow('output.send(new Uint8Array(), NaN)'); | 98 shouldThrow('output.send(new Uint8Array(), NaN)'); |
98 shouldThrow('output.send(new Uint8Array(), Infinity)'); | 99 shouldThrow('output.send(new Uint8Array(), Infinity)'); |
99 | 100 |
100 finishJSTest(); | 101 finishJSTest(); |
101 }, function () { | 102 }).catch(function () { |
102 testFailed("requestMIDIAccess() return an error."); | 103 testFailed("requestMIDIAccess() return an error."); |
103 }); | 104 }); |
104 | 105 |
105 </script> | 106 </script> |
106 </body> | 107 </body> |
107 </html> | 108 </html> |
OLD | NEW |