Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / webmidi / send-messages.html
blob0688c73ee6f3fa84a02be0964541b9b655b1edbb
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>
10 description("Test if various kinds of MIDI messages can be validated.");
12 shouldBeDefined("navigator.requestMIDIAccess");
14 window.jsTestIsAsync = true;
16 PermissionsHelper.setPermission('midi-sysex', 'granted').then(function() {
17 return navigator.requestMIDIAccess({sysex: true});
18 }).then(function(a) {
19 output = a.outputs.values().next().value;
21 // Note on(off).
22 output.send([0xff, 0x90, 0x00, 0x00, 0x90, 0x07, 0x00]);
24 // Running status is not allowed in Web MIDI API.
25 shouldThrow('output.send([0x00, 0x01])');
27 // Unexpected End of Sysex.
28 shouldThrow('output.send([0xf7])');
30 // Unexpected reserved status bytes.
31 shouldThrow('output.send([0xf4])');
32 shouldThrow('output.send([0xf5])');
33 shouldThrow('output.send([0xf9])');
34 shouldThrow('output.send([0xfd])');
36 // Incomplete channel messages.
37 shouldThrow('output.send([0x80])');
38 shouldThrow('output.send([0x80, 0x00])');
39 shouldThrow('output.send([0x90])');
40 shouldThrow('output.send([0x90, 0x00])');
41 shouldThrow('output.send([0xa0])');
42 shouldThrow('output.send([0xa0, 0x00])');
43 shouldThrow('output.send([0xb0])');
44 shouldThrow('output.send([0xb0, 0x00])');
45 shouldThrow('output.send([0xc0])');
46 shouldThrow('output.send([0xd0])');
47 shouldThrow('output.send([0xe0])');
48 shouldThrow('output.send([0xe0, 0x00])');
50 // Incomplete system messages.
51 shouldThrow('output.send([0xf1])');
52 shouldThrow('output.send([0xf2])');
53 shouldThrow('output.send([0xf2, 0x00])');
54 shouldThrow('output.send([0xf3])');
56 // Invalid data bytes.
57 shouldThrow('output.send([0x80, 0x80, 0x00])');
58 shouldThrow('output.send([0x80, 0x00, 0x80])');
60 // Complete messages.
61 output.send([0x80, 0x00, 0x00]);
62 output.send([0x90, 0x00, 0x00]);
63 output.send([0xa0, 0x00, 0x00]);
64 output.send([0xb0, 0x00, 0x00]);
65 output.send([0xc0, 0x00]);
66 output.send([0xd0, 0x00]);
67 output.send([0xe0, 0x00, 0x00]);
69 // Real-Time messages.
70 output.send([0xf8]);
71 output.send([0xfa]);
72 output.send([0xfb]);
73 output.send([0xfc]);
74 output.send([0xfe]);
75 output.send([0xff]);
77 // Valid messages with Real-Time messages.
78 output.send([0x90, 0xff, 0xff, 0x00, 0xff, 0x01, 0xff, 0x80, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff]);
80 // Sysex messages.
81 output.send([0xf0, 0x00, 0x01, 0x02, 0x03, 0xf7]);
82 output.send([0xf0, 0xf8, 0xf7, 0xff]);
83 shouldThrow('output.send([0xf0, 0x80, 0xf7])');
84 shouldThrow('output.send([0xf0, 0xf0, 0xf7])');
85 shouldThrow('output.send([0xf0, 0xff, 0xf7, 0xf7])');
87 // Reserved status bytes.
88 shouldThrow('output.send([0xf4, 0x80, 0x00, 0x00])');
89 shouldThrow('output.send([0x80, 0xf4, 0x00, 0x00])');
90 shouldThrow('output.send([0x80, 0x00, 0xf4, 0x00])');
91 shouldThrow('output.send([0x80, 0x00, 0x00, 0xf4])');
92 shouldThrow('output.send([0xf0, 0xff, 0xf4, 0xf7])');
94 // Invalid timestamps.
95 shouldThrow('output.send([], NaN)');
96 shouldThrow('output.send([], Infinity)');
97 shouldThrow('output.send(new Uint8Array(), NaN)');
98 shouldThrow('output.send(new Uint8Array(), Infinity)');
100 finishJSTest();
101 }).catch(function () {
102 testFailed("requestMIDIAccess() return an error.");
105 </script>
106 </body>
107 </html>