OLD | NEW |
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <link rel="stylesheet" href="../fast/js/resources/js-test-style.css"> | 4 <link rel="stylesheet" href="../fast/js/resources/js-test-style.css"> |
5 <script src="../fast/js/resources/js-test-pre.js"></script> | 5 <script src="../fast/js/resources/js-test-pre.js"></script> |
6 </head> | 6 </head> |
7 <body> | 7 <body> |
8 <p id="description"></p> | 8 <p id="description"></p> |
9 <div id="console"></div> | 9 <div id="console"></div> |
10 <script> | 10 <script> |
11 description("Tests navigator.requestMIDIAccess."); | 11 description("Tests navigator.requestMIDIAccess."); |
12 | 12 |
13 var access; | 13 var access; |
14 | 14 var output; |
15 function successCallback1(a) { | 15 function successCallback1(a) { |
16 access = a; | 16 access = a; |
17 | 17 |
18 testPassed('requestMIDIAccess() succeeded with access ' + access + '.'); | 18 testPassed('requestMIDIAccess() succeeded with access ' + access + '.'); |
19 | 19 |
20 // Validate that we have one mock input and one mock output. | 20 // Validate that we have one mock input and one mock output. |
21 shouldBe('access.inputs().length', '1'); | 21 shouldBe('access.inputs().length', '1'); |
22 shouldBe('access.outputs().length', '1'); | 22 shouldBe('access.outputs().length', '1'); |
23 | 23 |
24 var inputs = access.inputs(); | 24 var inputs = access.inputs(); |
25 var outputs = access.outputs(); | 25 var outputs = access.outputs(); |
26 var input = inputs[0]; | 26 var input = inputs[0]; |
27 var output = outputs[0]; | 27 output = outputs[0]; |
28 | 28 |
29 // Validate the values of the attributes on the input and output. | 29 // Validate the values of the attributes on the input and output. |
30 if (input.id == "MockInputID" && | 30 if (input.id == "MockInputID" && |
31 input.manufacturer == "MockInputManufacturer" && | 31 input.manufacturer == "MockInputManufacturer" && |
32 input.name == "MockInputName" && | 32 input.name == "MockInputName" && |
33 input.version == "MockInputVersion") { | 33 input.version == "MockInputVersion") { |
34 testPassed('input attributes are correct'); | 34 testPassed('input attributes are correct'); |
35 } else { | 35 } else { |
36 testFailed('input attributes are not correct'); | 36 testFailed('input attributes are not correct'); |
37 } | 37 } |
(...skipping 10 matching lines...) Expand all Loading... |
48 // Test sending of MIDI data with a Uint8Array. | 48 // Test sending of MIDI data with a Uint8Array. |
49 var typedArrayData = new Uint8Array([0x90, 0x45, 0x7f]); | 49 var typedArrayData = new Uint8Array([0x90, 0x45, 0x7f]); |
50 output.send(typedArrayData); | 50 output.send(typedArrayData); |
51 | 51 |
52 // Test sending of MIDI data with a regular Array. | 52 // Test sending of MIDI data with a regular Array. |
53 output.send([0x90, 0x45, 0x7f]); | 53 output.send([0x90, 0x45, 0x7f]); |
54 | 54 |
55 // Test sending of MIDI data with a regular Array giving an explicit timesta
mp. | 55 // Test sending of MIDI data with a regular Array giving an explicit timesta
mp. |
56 output.send([0x90, 0x45, 0x7f], performance.now()); | 56 output.send([0x90, 0x45, 0x7f], performance.now()); |
57 | 57 |
| 58 // Test sending system exclusive messages. These should throw, since we don'
t have sysex access. |
| 59 shouldThrow('output.send([0xf1, 0x45, 0x7f])', '"SecurityError: Failed to ex
ecute \'send\' on \'MIDIOutput\': permission to send system exclusive messages i
s denied."'); |
| 60 |
58 // Now test System Exclusive access - our test mock should not allow this ty
pe of access. | 61 // Now test System Exclusive access - our test mock should not allow this ty
pe of access. |
59 try { | 62 try { |
60 navigator.requestMIDIAccess( { sysex: true } ).then(successCallback2, er
rorCallback2); | 63 navigator.requestMIDIAccess( { sysex: true } ).then(successCallback2, er
rorCallback2); |
61 testPassed('navigator.requestMIDIAccess() did not throw exception.'); | 64 testPassed('navigator.requestMIDIAccess() did not throw exception.'); |
62 } catch(e) { | 65 } catch(e) { |
63 testFailed('navigator.requestMIDIAccess() should not throw exception.'); | 66 testFailed('navigator.requestMIDIAccess() should not throw exception.'); |
64 finishJSTest(); | 67 finishJSTest(); |
65 } | 68 } |
66 } | 69 } |
67 | 70 |
(...skipping 22 matching lines...) Expand all Loading... |
90 testFailed('navigator.requestMIDIAccess() should not throw exception.'); | 93 testFailed('navigator.requestMIDIAccess() should not throw exception.'); |
91 finishJSTest(); | 94 finishJSTest(); |
92 } | 95 } |
93 | 96 |
94 window.successfullyParsed = true; | 97 window.successfullyParsed = true; |
95 | 98 |
96 </script> | 99 </script> |
97 <script src="../fast/js/resources/js-test-post.js"></script> | 100 <script src="../fast/js/resources/js-test-post.js"></script> |
98 </body> | 101 </body> |
99 </html> | 102 </html> |
OLD | NEW |