chromium/third_party/blink/web_tests/wpt_internal/webmidi/open-close.https.html

<!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';
import {checkStateTransition} from './resources/state-check-utils.js';

const mock = new MockMIDIService();
async function runTests(port) {
  await checkStateTransition({
    port: port,
    method: "close",
    initialconnection: "closed",
    finalconnection: "closed",
  });

  await checkStateTransition({
    port: port,
    method: "open",
    initialconnection: "closed",
    finalconnection: "open",
  });

  await checkStateTransition({
    port: port,
    method: "open",
    initialconnection: "open",
    finalconnection: "open",
  });

  await checkStateTransition.bind({
    port: port,
    method: "close",
    initialconnection: "open",
    finalconnection: "closed",
  });
}

promise_test(async _ => {
  await test_driver.set_permission({name: 'midi', sysex: true}, 'granted');

  const access = await navigator.requestMIDIAccess();
  return runTests(access.inputs.values().next().value);
}, 'opening and closing MIDI devices');

</script>
</body>
</html>