summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webaudio/the-audio-api/the-channelmergernode-interface/audiochannelmerger-disconnect.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/webaudio/the-audio-api/the-channelmergernode-interface/audiochannelmerger-disconnect.html
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webaudio/the-audio-api/the-channelmergernode-interface/audiochannelmerger-disconnect.html')
-rw-r--r--testing/web-platform/tests/webaudio/the-audio-api/the-channelmergernode-interface/audiochannelmerger-disconnect.html82
1 files changed, 82 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webaudio/the-audio-api/the-channelmergernode-interface/audiochannelmerger-disconnect.html b/testing/web-platform/tests/webaudio/the-audio-api/the-channelmergernode-interface/audiochannelmerger-disconnect.html
new file mode 100644
index 0000000000..ad74d5e004
--- /dev/null
+++ b/testing/web-platform/tests/webaudio/the-audio-api/the-channelmergernode-interface/audiochannelmerger-disconnect.html
@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>
+ audiochannelmerger-disconnect.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 renderQuantum = 128;
+
+ let numberOfChannels = 2;
+ let sampleRate = 44100;
+ let renderDuration = 0.5;
+ let disconnectTime = 0.5 * renderDuration;
+
+ let audit = Audit.createTaskRunner();
+
+ // Task: Check if the merger outputs a silent channel when an input is
+ // disconnected.
+ audit.define('silent-disconnect', (task, should) => {
+ let context = new OfflineAudioContext(
+ numberOfChannels, renderDuration * sampleRate, sampleRate);
+ let merger = context.createChannelMerger();
+ let source1 = context.createBufferSource();
+ let source2 = context.createBufferSource();
+
+ // Create and assign a constant buffer.
+ let bufferDCOffset = createConstantBuffer(context, 1, 1);
+ source1.buffer = source2.buffer = bufferDCOffset;
+ source1.loop = source2.loop = true;
+
+ // Connect the output of source into the 4th input of merger. The merger
+ // should produce 6 channel output.
+ source1.connect(merger, 0, 0);
+ source2.connect(merger, 0, 1);
+ merger.connect(context.destination);
+ source1.start();
+ source2.start();
+
+ // Schedule the disconnection of |source2| at the half of render
+ // duration.
+ context.suspend(disconnectTime).then(function() {
+ source2.disconnect();
+ context.resume();
+ });
+
+ context.startRendering()
+ .then(function(buffer) {
+ // The entire first channel of the output should be 1.
+ should(buffer.getChannelData(0), 'Channel #0')
+ .beConstantValueOf(1);
+
+ // Calculate the first zero index in the second channel.
+ let channel1 = buffer.getChannelData(1);
+ let disconnectIndex = disconnectTime * sampleRate;
+ disconnectIndex = renderQuantum *
+ Math.floor(
+ (disconnectIndex + renderQuantum - 1) / renderQuantum);
+ let firstZeroIndex = channel1.findIndex(function(element, index) {
+ if (element === 0)
+ return index;
+ });
+
+ // The second channel should contain 1, and 0 after the
+ // disconnection.
+ should(channel1, 'Channel #1').containValues([1, 0]);
+ should(
+ firstZeroIndex, 'The index of first zero in the channel #1')
+ .beEqualTo(disconnectIndex);
+ })
+ .then(() => task.done());
+ });
+
+ audit.run();
+ </script>
+ </body>
+</html>