4 <script src=
"../resources/js-test.js"></script>
5 <script src=
"state-check-utils.js"></script>
9 description("Tests MIDIPort.open and MIDIPort.close.");
11 function runTests(port
) {
12 return Promise
.resolve().then(checkStateTransition
.bind(undefined, {
15 initialconnection
: "closed",
16 finalconnection
: "closed",
17 })).then(checkStateTransition
.bind(undefined, {
20 initialconnection
: "closed",
21 finalconnection
: "open",
22 })).then(checkStateTransition
.bind(undefined, {
25 initialconnection
: "open",
26 finalconnection
: "open",
27 })).then(checkStateTransition
.bind(undefined, {
30 initialconnection
: "open",
31 finalconnection
: "closed",
35 function successAccessCallback(a
) {
37 testPassed("requestMIDIAccess() succeeded with access " + access
+ ".");
39 runTests(access
.inputs
.values().next().value
)
40 .then(finishJSTest
, finishJSTest
);
43 function errorAccessCallback(error
) {
44 testFailed("requestMIDIAccess() error callback should not be called when requesting basic access.");
48 window
.jsTestIsAsync
= true;
50 // Test MIDIPort state transition by open() and close().
51 navigator
.requestMIDIAccess().then(successAccessCallback
, errorAccessCallback
);