<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
</head>
<body>
<script type="module">
import {MockMIDIService} from './resources/mock-midiservice.js';
const mock = new MockMIDIService();
const options = [
{},
{ sysex: false },
{ sysex: true }
];
const permissions = [
{ midi: 'denied', sysex: 'denied' },
{ midi: 'granted', sysex: 'denied' },
{ midi: 'granted', sysex: 'granted' }
];
promise_test(async _ => {
for (const permission of permissions) {
for (const option of options) {
await test_driver.set_permission({name: 'midi'}, permission.midi);
await test_driver.set_permission({name: 'midi', sysex: true},
permission.sysex);
try {
const access = await navigator.requestMIDIAccess(option);
assert_equals(permission.midi, 'granted');
if (option.sysex) {
assert_equals(permission.sysex, 'granted');
}
} catch (e) {
if (option.sysex) {
assert_equals(permission.sysex, 'denied');
} else {
assert_true((permission.midi == 'denied') ||
(permission.sysex == 'denied'));
}
}
}
}
}, 'requestMIDIAccess with various options');
</script>
</body>
</html>