chromium/third_party/blink/web_tests/wpt_internal/webmidi/requestmidiaccess-upgrade.https.html

<!DOCTYPE html>
<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>
<script type="module">
import {MockMIDIService} from './resources/mock-midiservice.js';

const mock = new MockMIDIService();
promise_test(async () => {
  // Obtain the first MIDIAccess instance
  await test_driver.set_permission({name: 'midi', sysex: true}, 'granted');
  const nosysex_access = await navigator.requestMIDIAccess();

  // See if a sysex message can not be sent over the first instance.
  const nosysex_outport = nosysex_access.outputs.values().next().value;
  const sysex_message = [0xf0, 0x00, 0x01, 0x02, 0xf7];

  assert_throws_dom("InvalidAccessError", () => {
    nosysex_outport.send(sysex_message);
  });

  // Obtain the second MIDIAccess instance with a sysex permission.
  await test_driver.set_permission({name: 'midi', sysex: true}, 'granted');
  const sysex_access = await navigator.requestMIDIAccess({sysex: true});

  // See if a sysex message can be sent correctly over the second instance.
  const sysex_loopback_inport = sysex_access.inputs.values().next().value;
  const received_data = await new Promise((resolve, reject) => {
    sysex_loopback_inport.onmidimessage = e => resolve(e.data);
    const sysex_outport = sysex_access.outputs.values().next().value;
    sysex_outport.send(sysex_message);
  });
  assert_array_equals(sysex_message, received_data);
}, "Test if the second MIDIAccess with stronger authority works correctly");
</script>