| 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 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <script> | 7 <script> |
| 8 | 8 |
| 9 description("Test if sysex permission request is handled."); | 9 description("Test if sysex permission request is handled."); |
| 10 | 10 |
| 11 shouldBeDefined("testRunner.setMIDISysExPermission"); | 11 shouldBeDefined("testRunner.setMIDISysExPermission"); |
| 12 shouldBeDefined("navigator.requestMIDIAccess"); | 12 shouldBeDefined("navigator.requestMIDIAccess"); |
| 13 | 13 |
| 14 window.jsTestIsAsync = true; | 14 window.jsTestIsAsync = true; |
| 15 | 15 |
| 16 var finishSuccessfully = function () { | 16 var finishSuccessfully = function () { |
| 17 testPassed("all permission request rests pass successfully."); | 17 testPassed("all permission request rests pass successfully."); |
| 18 finishJSTest(); | 18 finishJSTest(); |
| 19 } | 19 } |
| 20 | 20 |
| 21 var rejectSysEx = function (next) { | 21 var rejectSysEx = function (next) { |
| 22 testRunner.setMIDISysExPermission(false); | 22 testRunner.setMIDISysExPermission(false); |
| 23 shouldNotThrow("promise = navigator.requestMIDIAccess({sysex: true})"); | 23 promise = navigator.requestMIDIAccess({sysex: true}); |
| 24 shouldBeDefined("promise"); | 24 shouldBeDefined("promise"); |
| 25 shouldBeDefined("promise.then"); | 25 shouldBeDefined("promise.then"); |
| 26 promise.then(function(access) { | 26 promise.then(function(access) { |
| 27 testFailed("sysex permission request should be rejected."); | 27 testFailed("sysex permission request should be rejected."); |
| 28 finishJSTest(); | 28 finishJSTest(); |
| 29 }, function (error) { | 29 }, function (error) { |
| 30 testPassed("sysex permission request is successfully rejected."); | 30 testPassed("sysex permission request is successfully rejected."); |
| 31 if (next) | 31 if (next) |
| 32 next(); | 32 next(); |
| 33 else | 33 else |
| 34 finishSuccessfully(); | 34 finishSuccessfully(); |
| 35 }); | 35 }); |
| 36 } | 36 } |
| 37 | 37 |
| 38 var acceptSysEx = function (next) { | 38 var acceptSysEx = function (next) { |
| 39 testRunner.setMIDISysExPermission(true); | 39 testRunner.setMIDISysExPermission(true); |
| 40 shouldNotThrow("promise = navigator.requestMIDIAccess({sysex: true})"); | 40 promise = navigator.requestMIDIAccess({sysex: true}); |
| 41 shouldBeDefined("promise"); | 41 shouldBeDefined("promise"); |
| 42 shouldBeDefined("promise.then"); | 42 shouldBeDefined("promise.then"); |
| 43 promise.then(function(access) { | 43 promise.then(function(access) { |
| 44 testPassed("sysex permission request is successfully accepted."); | 44 testPassed("sysex permission request is successfully accepted."); |
| 45 if (next) | 45 if (next) |
| 46 next(); | 46 next(); |
| 47 else | 47 else |
| 48 finishSuccessfully(); | 48 finishSuccessfully(); |
| 49 }, function (error) { | 49 }, function (error) { |
| 50 testFailed("sysex permission request should be accepted."); | 50 testFailed("sysex permission request should be accepted."); |
| 51 finishJSTest(); | 51 finishJSTest(); |
| 52 }); | 52 }); |
| 53 } | 53 } |
| 54 | 54 |
| 55 rejectSysEx(acceptSysEx); | 55 rejectSysEx(acceptSysEx); |
| 56 | 56 |
| 57 </script> | 57 </script> |
| 58 </body> | 58 </body> |
| 59 </html> | 59 </html> |
| OLD | NEW |