4 <title>WebMIDI MIDIMessageEvent Test
</title>
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
7 <script type=
"application/javascript" src=
"MIDITestUtils.js"></script>
11 <script class=
"testbody" type=
"application/javascript">
12 add_task(async () =
> {
13 await MIDITestUtils.permissionSetup(true);
15 is(new MIDIMessageEvent('eventType').bubbles, false,
"bubbles field is false by default");
16 is(new MIDIMessageEvent('eventType').cancelable, false,
"cancelable field is false by default");
17 isDeeply(new MIDIMessageEvent('eventType').data, [],
"The default message is empty");
19 is(new MIDIMessageEvent('eventType', { bubbles: false }).bubbles, false,
"bubbles is passed");
20 is(new MIDIMessageEvent('eventType', { bubbles: true }).bubbles, true,
"bubbles is passed");
22 is(new MIDIMessageEvent('eventType', { cancelable: false }).cancelable, false,
"cancelable is passed");
23 is(new MIDIMessageEvent('eventType', { cancelable: true }).cancelable, true,
"cancelable is passed");
25 var data = new Uint8Array(
16);
26 isDeeply(new MIDIMessageEvent('eventType', { data }).data, data,
"data is passed");
28 // All initializers are passed.
29 data = new Uint8Array(
3);
30 is(new MIDIMessageEvent('eventType', { bubbles: true, cancelable: true, data }).bubbles, true,
"all initializers are passed");
31 is(new MIDIMessageEvent('eventType', { bubbles: true, cancelable: true, data }).cancelable, true,
"all initializers are passed");
32 isDeeply(new MIDIMessageEvent('eventType', { bubbles: true, cancelable: true, data }).data, data,
"all initializers are passed");
34 if (window.SharedArrayBuffer) {
35 data = new Uint8Array(new SharedArrayBuffer(
3));
36 SimpleTest.doesThrow(() =
> { new MIDIMessageEvent('eventType', { data }); },
"shared array buffers are rejected");
38 todo(false, 'SharedArrayBuffer is unavailable.');