OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 <html> |
| 3 <head> |
| 4 <link rel="stylesheet" href="../fast/js/resources/js-test-style.css"> |
| 5 <script src="../fast/js/resources/js-test-pre.js"></script> |
| 6 </head> |
| 7 <body> |
| 8 <p id="description"></p> |
| 9 <div id="console"></div> |
| 10 <script> |
| 11 description("Tests navigator.requestMIDIAccess."); |
| 12 |
| 13 var access; |
| 14 |
| 15 function successCallback1(a) { |
| 16 access = a; |
| 17 |
| 18 testPassed('requestMIDIAccess() succeeded with access ' + access + '.'); |
| 19 |
| 20 // Validate that we have one mock input and one mock output. |
| 21 shouldBe('access.inputs().length', '1'); |
| 22 shouldBe('access.outputs().length', '1'); |
| 23 |
| 24 var inputs = access.inputs(); |
| 25 var outputs = access.outputs(); |
| 26 var input = inputs[0]; |
| 27 var output = outputs[0]; |
| 28 |
| 29 // Validate the values of the attributes on the input and output. |
| 30 if (input.id == "MockInputID" && |
| 31 input.manufacturer == "MockInputManufacturer" && |
| 32 input.name == "MockInputName" && |
| 33 input.version == "MockInputVersion") { |
| 34 testPassed('input attributes are correct'); |
| 35 } else { |
| 36 testFailed('input attributes are not correct'); |
| 37 } |
| 38 |
| 39 if (output.id == "MockOutputID" && |
| 40 output.manufacturer == "MockOutputManufacturer" && |
| 41 output.name == "MockOutputName" && |
| 42 output.version == "MockOutputVersion") { |
| 43 testPassed('output attributes are correct'); |
| 44 } else { |
| 45 testFailed('output attributes are not correct'); |
| 46 } |
| 47 |
| 48 // Now test System Exclusive access - our test mock should not allow this ty
pe of access. |
| 49 try { |
| 50 navigator.requestMIDIAccess( { sysexEnabled: true } ).then(successCallba
ck2, errorCallback2); |
| 51 testPassed('navigator.requestMIDIAccess() did not throw exception.'); |
| 52 } catch(e) { |
| 53 testFailed('navigator.requestMIDIAccess() should not throw exception.'); |
| 54 finishJSTest(); |
| 55 } |
| 56 } |
| 57 |
| 58 function errorCallback1(error) { |
| 59 testFailed('requestMIDIAccess() error callback should not be called when req
uesting basic access.'); |
| 60 finishJSTest(); |
| 61 } |
| 62 |
| 63 function successCallback2(access) { |
| 64 testFailed('requestMIDIAccess() was not correctly blocked for System Exclusi
ve access.'); |
| 65 finishJSTest(); |
| 66 } |
| 67 |
| 68 function errorCallback2(error) { |
| 69 testPassed('requestMIDIAccess() was correctly blocked for System Exclusive a
ccess with error ' + error + '.'); |
| 70 finishJSTest(); |
| 71 } |
| 72 |
| 73 window.jsTestIsAsync = true; |
| 74 |
| 75 // Test basic access, with no System Exclusive. |
| 76 try { |
| 77 navigator.requestMIDIAccess().then(successCallback1, errorCallback1); |
| 78 testPassed('navigator.requestMIDIAccess() did not throw exception.'); |
| 79 } catch(e) { |
| 80 testFailed('navigator.requestMIDIAccess() should not throw exception.'); |
| 81 finishJSTest(); |
| 82 } |
| 83 |
| 84 window.successfullyParsed = true; |
| 85 |
| 86 </script> |
| 87 <script src="../fast/js/resources/js-test-post.js"></script> |
| 88 </body> |
| 89 </html> |
OLD | NEW |