4 <script src=
"../resources/js-test.js"></script>
5 <script src=
"../http/tests/resources/permissions-helper.js"></script>
10 description("Test if sysex permission request is handled.");
12 shouldBeDefined("navigator.requestMIDIAccess");
13 shouldBeDefined("PermissionsHelper.setPermission");
15 window
.jsTestIsAsync
= true;
17 var finishSuccessfully = function () {
18 testPassed("all permission request rests pass successfully.");
22 var rejectSysex = function (next
) {
23 PermissionsHelper
.setPermission('midi-sysex', 'denied').then(function() {
24 promise
= navigator
.requestMIDIAccess({sysex
: true});
25 shouldBeDefined("promise");
26 shouldBeDefined("promise.then");
27 promise
.then(function(access
) {
28 testFailed("sysex permission request should be rejected.");
31 testPassed("sysex permission request is successfully rejected.");
40 var acceptSysex = function (next
) {
41 PermissionsHelper
.setPermission('midi-sysex', 'granted').then(function() {
42 promise
= navigator
.requestMIDIAccess({sysex
: true});
43 shouldBeDefined("promise");
44 shouldBeDefined("promise.then");
45 promise
.then(function(obtainedAccess
) {
46 testPassed("sysex permission request is successfully accepted.");
47 access
= obtainedAccess
;
48 shouldBeDefined("access");
49 shouldBeDefined("access.sysexEnabled");
50 shouldBeTrue("access.sysexEnabled");
56 testFailed("sysex permission request should be accepted.");
62 rejectSysex(acceptSysex
);