Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / webmidi / loopback-receive.html
blob9728155a3a70d1aa81c44e2be35522c4705aa1d1
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../resources/js-test.js"></script>
5 <script src="../http/tests/resources/permissions-helper.js"></script>
6 </head>
7 <body>
8 <script>
10 description("Test if midimessage event handler work.");
12 shouldBeDefined("navigator.requestMIDIAccess");
14 window.jsTestIsAsync = true;
16 testData = [
17 // Complete messages.
18 [0x80, 0x00, 0x00],
19 [0x90, 0x00, 0x00],
20 [0xa0, 0x00, 0x00],
21 [0xb0, 0x00, 0x00],
22 [0xc0, 0x00],
23 [0xd0, 0x00],
24 [0xe0, 0x00, 0x00],
26 // Real-Time messages.
27 [0xf8],
28 [0xfa],
29 [0xfb],
30 [0xfc],
31 [0xfe],
32 [0xff],
34 // Sysex messages.
35 [0xf0, 0x00, 0x01, 0x02, 0x03, 0xf7],
36 [0xf0, 0xf8, 0xf7],
39 receiveCount = 0;
41 function verifyData(e) {
42 debug("receiving data " + receiveCount + ": " + e.data);
43 expected = testData[receiveCount];
44 actual = e.data;
45 shouldBe("actual", "expected");
46 receiveCount++;
47 if (receiveCount == testData.length)
48 e.target.resolve();
51 function test(useAddEventListener) {
52 return new Promise(function(resolve, reject) {
53 debug("running test with useAddEventListener = " + useAddEventListener);
54 navigator.requestMIDIAccess({sysex: true}).then(function (a) {
55 receiveCount = 0;
56 var input = a.inputs.values().next().value;
57 input.resolve = resolve;
58 input.reject = reject;
59 if (useAddEventListener) {
60 input.addEventListener('midimessage', verifyData);
61 } else {
62 input.onmidimessage = verifyData;
64 var output = a.outputs.values().next().value;
65 for (var i = 0; i < testData.length; ++i)
66 output.send(testData[i]);
67 }, function () {
68 testFailed("requestMIDIAccess() return an error.");
69 reject();
70 });
71 });
74 PermissionsHelper.setPermission('midi-sysex', 'granted').then(function() {
75 test(false).then(test.bind(null, true)).then(finishJSTest, finishJSTest);
76 });
78 </script>
79 </body>
80 </html>