| 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.setPermission"); |
| 11 shouldBeDefined("testRunner.setMIDISysexPermission"); | 12 shouldBeDefined("testRunner.setMIDISysexPermission"); |
| 12 shouldBeDefined("navigator.requestMIDIAccess"); | 13 shouldBeDefined("navigator.requestMIDIAccess"); |
| 13 | 14 |
| 14 window.jsTestIsAsync = true; | 15 window.jsTestIsAsync = true; |
| 15 | 16 |
| 16 var finishSuccessfully = function () { | 17 var finishSuccessfully = function () { |
| 17 testPassed("all permission request rests pass successfully."); | 18 testPassed("all permission request rests pass successfully."); |
| 18 finishJSTest(); | 19 finishJSTest(); |
| 19 } | 20 } |
| 20 | 21 |
| 21 var rejectSysex = function (next) { | 22 var rejectSysex = function (next) { |
| 23 testRunner.setPermission('midi-sysex', 'denied', location.origin, location.o
rigin); |
| 22 testRunner.setMIDISysexPermission(false); | 24 testRunner.setMIDISysexPermission(false); |
| 23 promise = navigator.requestMIDIAccess({sysex: true}); | 25 promise = navigator.requestMIDIAccess({sysex: true}); |
| 24 shouldBeDefined("promise"); | 26 shouldBeDefined("promise"); |
| 25 shouldBeDefined("promise.then"); | 27 shouldBeDefined("promise.then"); |
| 26 promise.then(function(access) { | 28 promise.then(function(access) { |
| 27 testFailed("sysex permission request should be rejected."); | 29 testFailed("sysex permission request should be rejected."); |
| 28 finishJSTest(); | 30 finishJSTest(); |
| 29 }, function (error) { | 31 }, function (error) { |
| 30 testPassed("sysex permission request is successfully rejected."); | 32 testPassed("sysex permission request is successfully rejected."); |
| 31 if (next) | 33 if (next) |
| 32 next(); | 34 next(); |
| 33 else | 35 else |
| 34 finishSuccessfully(); | 36 finishSuccessfully(); |
| 35 }); | 37 }); |
| 36 } | 38 } |
| 37 | 39 |
| 38 var acceptSysex = function (next) { | 40 var acceptSysex = function (next) { |
| 41 testRunner.setPermission('midi-sysex', 'granted', location.origin, location.
origin); |
| 39 testRunner.setMIDISysexPermission(true); | 42 testRunner.setMIDISysexPermission(true); |
| 40 promise = navigator.requestMIDIAccess({sysex: true}); | 43 promise = navigator.requestMIDIAccess({sysex: true}); |
| 41 shouldBeDefined("promise"); | 44 shouldBeDefined("promise"); |
| 42 shouldBeDefined("promise.then"); | 45 shouldBeDefined("promise.then"); |
| 43 promise.then(function(obtainedAccess) { | 46 promise.then(function(obtainedAccess) { |
| 44 testPassed("sysex permission request is successfully accepted."); | 47 testPassed("sysex permission request is successfully accepted."); |
| 45 access = obtainedAccess; | 48 access = obtainedAccess; |
| 46 shouldBeDefined("access"); | 49 shouldBeDefined("access"); |
| 47 shouldBeDefined("access.sysexEnabled"); | 50 shouldBeDefined("access.sysexEnabled"); |
| 48 shouldBeTrue("access.sysexEnabled"); | 51 shouldBeTrue("access.sysexEnabled"); |
| 49 if (next) | 52 if (next) |
| 50 next(); | 53 next(); |
| 51 else | 54 else |
| 52 finishSuccessfully(); | 55 finishSuccessfully(); |
| 53 }, function (error) { | 56 }, function (error) { |
| 54 testFailed("sysex permission request should be accepted."); | 57 testFailed("sysex permission request should be accepted."); |
| 55 finishJSTest(); | 58 finishJSTest(); |
| 56 }); | 59 }); |
| 57 } | 60 } |
| 58 | 61 |
| 59 rejectSysex(acceptSysex); | 62 rejectSysex(acceptSysex); |
| 60 | 63 |
| 61 </script> | 64 </script> |
| 62 </body> | 65 </body> |
| 63 </html> | 66 </html> |
| OLD | NEW |