4 <script src=
"../resources/js-test.js"></script>
5 <script src=
"state-check-utils.js"></script>
9 description("Tests MIDIPort implicit open.");
11 function resetInputDevice(port
) {
12 debug("- reset input device");
13 // Reset event handlers so that close() does not cause check failures.
14 port
.onstatechange
= null;
15 access
.onstatechange
= null;
17 return Promise
.resolve();
20 function successAccessCallback(a
) {
22 testPassed("requestMIDIAccess() succeeded with access " + access
+ ".");
24 var inputPort
= access
.inputs
.values().next().value
;
25 var outputPort
= access
.outputs
.values().next().value
;
27 checkStateTransition({
29 method
: "setonmidimessage",
30 initialconnection
: "closed",
31 finalconnection
: "open" }
32 ).then(resetInputDevice
.bind(undefined, inputPort
33 )).then(checkStateTransition
.bind(undefined, {
35 method
: "addeventlistener",
36 initialconnection
: "closed",
37 finalconnection
: "open" }
38 )).then(checkStateTransition
.bind(undefined, {
41 initialconnection
: "closed",
42 finalconnection
: "open" }
43 )).then(finishJSTest
, finishJSTest
);
46 function errorAccessCallback(error
) {
47 testFailed("requestMIDIAccess() error callback should not be called when requesting basic access.");
51 window
.jsTestIsAsync
= true;
53 // Test MIDIPort state transition by send() and onmidimessage handler.
54 navigator
.requestMIDIAccess().then(successAccessCallback
, errorAccessCallback
);