summaryrefslogtreecommitdiffstats
path: root/dom/midi/tests/test_midi_message_event.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /dom/midi/tests/test_midi_message_event.html
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/midi/tests/test_midi_message_event.html')
-rw-r--r--dom/midi/tests/test_midi_message_event.html45
1 files changed, 45 insertions, 0 deletions
diff --git a/dom/midi/tests/test_midi_message_event.html b/dom/midi/tests/test_midi_message_event.html
new file mode 100644
index 0000000000..098b033008
--- /dev/null
+++ b/dom/midi/tests/test_midi_message_event.html
@@ -0,0 +1,45 @@
+<html>
+
+<head>
+ <title>WebMIDI MIDIMessageEvent Test</title>
+ <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+ <script type="application/javascript" src="MIDITestUtils.js"></script>
+</head>
+
+<body>
+ <script class="testbody" type="application/javascript">
+ add_task(async () => {
+ await MIDITestUtils.permissionSetup(true);
+
+ is(new MIDIMessageEvent('eventType').bubbles, false, "bubbles field is false by default");
+ is(new MIDIMessageEvent('eventType').cancelable, false, "cancelable field is false by default");
+ isDeeply(new MIDIMessageEvent('eventType').data, [], "The default message is empty");
+
+ is(new MIDIMessageEvent('eventType', { bubbles: false }).bubbles, false, "bubbles is passed");
+ is(new MIDIMessageEvent('eventType', { bubbles: true }).bubbles, true, "bubbles is passed");
+
+ is(new MIDIMessageEvent('eventType', { cancelable: false }).cancelable, false, "cancelable is passed");
+ is(new MIDIMessageEvent('eventType', { cancelable: true }).cancelable, true, "cancelable is passed");
+
+ var data = new Uint8Array(16);
+ isDeeply(new MIDIMessageEvent('eventType', { data }).data, data, "data is passed");
+
+ // All initializers are passed.
+ data = new Uint8Array(3);
+ is(new MIDIMessageEvent('eventType', { bubbles: true, cancelable: true, data }).bubbles, true, "all initializers are passed");
+ is(new MIDIMessageEvent('eventType', { bubbles: true, cancelable: true, data }).cancelable, true, "all initializers are passed");
+ isDeeply(new MIDIMessageEvent('eventType', { bubbles: true, cancelable: true, data }).data, data, "all initializers are passed");
+
+ if (window.SharedArrayBuffer) {
+ data = new Uint8Array(new SharedArrayBuffer(3));
+ SimpleTest.doesThrow(() => { new MIDIMessageEvent('eventType', { data }); }, "shared array buffers are rejected");
+ } else {
+ todo(false, 'SharedArrayBuffer is unavailable.');
+ }
+ });
+ </script>
+</body>
+
+</html>