summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.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 /testing/web-platform/tests/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.html
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.html')
-rw-r--r--testing/web-platform/tests/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.html71
1 files changed, 71 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.html b/testing/web-platform/tests/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.html
new file mode 100644
index 0000000000..a2c4581c4e
--- /dev/null
+++ b/testing/web-platform/tests/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.html
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>
+ audiobuffer.html
+ </title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/webaudio/resources/audit-util.js"></script>
+ <script src="/webaudio/resources/audit.js"></script>
+ </head>
+ <body>
+ <script id="layout-test-code">
+ let sampleRate = 44100.0
+ let lengthInSeconds = 2;
+ let numberOfChannels = 4;
+
+ let audit = Audit.createTaskRunner();
+
+ audit.define('Basic tests for AudioBuffer', function(task, should) {
+ let context = new AudioContext();
+ let buffer = context.createBuffer(
+ numberOfChannels, sampleRate * lengthInSeconds, sampleRate);
+
+ // Just for printing out a message describing what "buffer" is in the
+ // following tests.
+ should(
+ true,
+ 'buffer = context.createBuffer(' + numberOfChannels + ', ' +
+ (sampleRate * lengthInSeconds) + ', ' + sampleRate + ')')
+ .beTrue();
+
+ should(buffer.sampleRate, 'buffer.sampleRate').beEqualTo(sampleRate);
+
+ should(buffer.length, 'buffer.length')
+ .beEqualTo(sampleRate * lengthInSeconds);
+
+ should(buffer.duration, 'buffer.duration').beEqualTo(lengthInSeconds);
+
+ should(buffer.numberOfChannels, 'buffer.numberOfChannels')
+ .beEqualTo(numberOfChannels);
+
+ for (let index = 0; index < buffer.numberOfChannels; ++index) {
+ should(
+ buffer.getChannelData(index) instanceof window.Float32Array,
+ 'buffer.getChannelData(' + index +
+ ') instanceof window.Float32Array')
+ .beTrue();
+ }
+
+ should(
+ function() {
+ buffer.getChannelData(buffer.numberOfChannels);
+ },
+ 'buffer.getChannelData(' + buffer.numberOfChannels + ')')
+ .throw(DOMException, 'IndexSizeError');
+
+ let buffer2 = context.createBuffer(1, 1000, 24576);
+ let expectedDuration = 1000 / 24576;
+
+ should(
+ buffer2.duration, 'context.createBuffer(1, 1000, 24576).duration')
+ .beEqualTo(expectedDuration);
+
+ task.done();
+ });
+
+ audit.run();
+ </script>
+ </body>
+</html>