Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Unified Diff: third_party/WebKit/LayoutTests/webmidi/add-port.html

Issue 2487113002: Web MIDI: fix a regression of r430234 (Closed)
Patch Set: review #18 Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/webmidi/add-port.html
diff --git a/third_party/WebKit/LayoutTests/webmidi/add-port.html b/third_party/WebKit/LayoutTests/webmidi/add-port.html
new file mode 100644
index 0000000000000000000000000000000000000000..6bb9f46000d6f14428e62e0ef8d7caeed0ddc16c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/webmidi/add-port.html
@@ -0,0 +1,75 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../resources/js-test.js"></script>
tkent 2016/11/14 06:34:02 Do you have any reason to avoid testharness.js ?
Takashi Toyoshima 2016/11/14 07:53:43 Done.
+<script src="../http/tests/resources/permissions-helper.js"></script>
+</head>
+<body>
+<script>
+
+description("Test if newly connected ports work correctly.");
+
+window.jsTestIsAsync = true;
+
+var sysexHeader = [0xf0, 0x00, 0x02, 0x0d, 0x7f];
+var sysexFooter = [0xf7];
+var sysexPayloadToAddInputAsConnected = [0x00, 0x00];
+var sysexPayloadToAddOutputAsConnected = [0x00, 0x01];
+var sysexPayloadToAddInputAsOpened = [0x00, 0x02];
+var sysexPayloadToAddOutputAsOpened = [0x00, 0x03];
+var noteOn = [0x90, 0x45, 0x7f];
+
+function createSysex(payload) {
+ return sysexHeader.concat(payload).concat(sysexFooter);
+}
+
+var receivedMessages = 0;
+
+function receiveMessage(e) {
+ event = e;
+ shouldBe("event.data", "noteOn");
+ if (++receivedMessages != 2)
+ return;
+ finishJSTest();
+}
+
+Promise.all([PermissionsHelper.setPermission('midi', 'granted'),
+ PermissionsHelper.setPermission('midi-sysex', 'granted')]).then(function() {
+ return navigator.requestMIDIAccess({sysex: true});
+ }).then(function(a) {
tkent 2016/11/14 06:34:02 Indentation is inconsistent. This |then| line and
Takashi Toyoshima 2016/11/14 07:53:43 Done.
+ var started = false;
+ a.onstatechange = function(e) {
+ // Wait until three outputs and three inputs appear.
+ if (a.inputs.size != 3 || a.outputs.size != 3 || started)
+ return;
+ started = true;
+ testPassed("Test devices are newly added correctly.");
+
+ // Set an event handler respectively for newly connected ports.
+ var inputs = a.inputs.values();
+ inputs.next();
+ inputs.next().value.onmidimessage = receiveMessage;
+ inputs.next().value.onmidimessage = receiveMessage;
+
+ // Send a message respectively, and see if it is loopbacked.
+ var outputs = a.outputs.values();
+ outputs.next();
+ outputs.next().value.send(noteOn);
+ outputs.next().value.send(noteOn);
+ };
+
+ output = a.outputs.values().next().value;
+
+ // Send sysex messages to request dynamically adding mock devices.
+ output.send(createSysex(sysexPayloadToAddInputAsConnected));
+ output.send(createSysex(sysexPayloadToAddOutputAsConnected));
+ output.send(createSysex(sysexPayloadToAddInputAsOpened));
+ output.send(createSysex(sysexPayloadToAddOutputAsOpened));
+}).catch(function () {
+ testFailed("unexpected error: " + e);
+ finishJSTest();
+});
+
+</script>
+</body>
+</html>
« no previous file with comments | « components/test_runner/mock_web_midi_accessor.cc ('k') | third_party/WebKit/LayoutTests/webmidi/add-port-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698