Index: LayoutTests/webmidi/open-close.html |
diff --git a/LayoutTests/webmidi/open-close.html b/LayoutTests/webmidi/open-close.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3b09bc612fddba5a1ac98c087eacb91f4d149d75 |
--- /dev/null |
+++ b/LayoutTests/webmidi/open-close.html |
@@ -0,0 +1,55 @@ |
+<!DOCTYPE html> |
+<html> |
+<head> |
+<script src="../resources/js-test.js"></script> |
+<script src="state-check-utils.js"></script> |
+</head> |
+<body> |
+<script> |
+description("Tests MIDIPort.open and MIDIPort.close."); |
+ |
+function runTests(port) { |
+ return Promise.resolve().then(checkStateTransition.bind(undefined, { |
+ port: port, |
+ method: "close", |
+ initialconnection: "closed", |
+ finalconnection: "closed", |
+ })).then(checkStateTransition.bind(undefined, { |
+ port: port, |
+ method: "open", |
+ initialconnection: "closed", |
+ finalconnection: "open", |
+ })).then(checkStateTransition.bind(undefined, { |
+ port: port, |
+ method: "open", |
+ initialconnection: "open", |
+ finalconnection: "open", |
+ })).then(checkStateTransition.bind(undefined, { |
+ port: port, |
+ method: "close", |
+ initialconnection: "open", |
+ finalconnection: "closed", |
+ })); |
+} |
+ |
+function successAccessCallback(a) { |
+ window.access = a; |
+ testPassed("requestMIDIAccess() succeeded with access " + access + "."); |
+ |
+ runTests(access.inputs.values().next().value) |
+ .then(finishJSTest, finishJSTest); |
+} |
+ |
+function errorAccessCallback(error) { |
+ testFailed("requestMIDIAccess() error callback should not be called when requesting basic access."); |
+ finishJSTest(); |
+} |
+ |
+window.jsTestIsAsync = true; |
+ |
+// Test MIDIPort state transition by open() and close(). |
+navigator.requestMIDIAccess().then(successAccessCallback, errorAccessCallback); |
+ |
+</script> |
+</body> |
+</html> |