blob: dae68a38754299bda28acdcd42eef07576048438 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>Permissions API: test midi sysex on insecure origins.</title>
<script src='../resources/testharness.js'></script>
<script src='../resources/testharnessreport.js'></script>
<script src='../resources/get-host-info.js'></script>
</head>
<body>
<script>
// Midi SysEx is not available on insecure origins. This is testing that the
// Permissions API matches navigator.requestMIDIAccess() behaviour.
// In the context of Chromium's LayoutTests, this test is a dummy test because
// the Permissions API and requestMIDIAccess calls are using a mock
// implementation of the backend. However, the test can be used in different
// context.
if (window.location.origin != get_host_info().UNAUTHENTICATED_ORIGIN) {
window.location = get_host_info().UNAUTHENTICATED_ORIGIN + window.location.pathname;
} else {
async_test(function() {
navigator.requestMIDIAccess({sysex:true}).then(this.step_func(function() {
assert_unreached('requesting midi access should fail');
this.done();
})).catch(this.step_func(function(e) {
assert_equals(e.name, 'SecurityError')
return navigator.permissions.query({name:'midi', sysex:true});
})).then(this.step_func(function(p) {
assert_equals(p.state, "denied");
this.done();
}));
}, 'requesting midi access and querying them should both return deny.');
}
</script>
</body>
</html>