tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit bb0db8d96356d753e1f980b590270b0aa0029946
parent a438b74afb3a64b139ed1479fe55d455cb5405d0
Author: punithbnayak <punithbnayak@chromium.org>
Date:   Thu,  6 Nov 2025 21:37:39 +0000

Bug 1998001 [wpt PR 55832] - [webaudio-testharness] Migrate audiochannelmerger-disconnect.html, a=testonly

Automatic update from web-platform-tests
[webaudio-testharness] Migrate audiochannelmerger-disconnect.html

Convert audiochannelmerger-disconnect.html from the legacy
audit.js runner to pure testharness.js

Change-Id: I363dfc38baddbd78c53c69d7a493507238dfc1e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7037373
Reviewed-by: Michael Wilson <mjwilson@chromium.org>
Commit-Queue: Punith Nayak <punithbnayak@chromium.org>
Reviewed-by: Hongchan Choi <hongchan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1539566}

--

wpt-commits: ec39b7067c1be53368317a1fbf78e9c0df9c5179
wpt-pr: 55832

Diffstat:
Mtesting/web-platform/tests/webaudio/the-audio-api/the-channelmergernode-interface/audiochannelmerger-disconnect.html | 86++++++++++++++++++++++++++++++++++---------------------------------------------
1 file changed, 37 insertions(+), 49 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 @@ -2,40 +2,32 @@ <html> <head> <title> - audiochannelmerger-disconnect.html + ChannelMergerNode: Asynchronous disconnect() correctly silences the + output </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(); + <script> + const renderQuantum = 128; + const numberOfChannels = 2; + const sampleRate = 44100; + const renderDuration = 0.5; + const disconnectTime = 0.5 * renderDuration; // Task: Check if the merger outputs a silent channel when an input is // disconnected. - audit.define('silent-disconnect', (task, should) => { - let context = new OfflineAudioContext( + promise_test(async () => { + const context = new OfflineAudioContext( numberOfChannels, renderDuration * sampleRate, sampleRate); - let merger = context.createChannelMerger(); - let source1 = context.createBufferSource(); - let source2 = context.createBufferSource(); + const merger = new ChannelMergerNode(context, {numberOfInputs: 6}); + const source1 = new ConstantSourceNode(context, {offset: 1.0}); + const source2 = new ConstantSourceNode(context, {offset: 1.0}); - // 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. + // Connect the sources to the first two inputs of the merger. + // The merger should produce 6 channel output. source1.connect(merger, 0, 0); source2.connect(merger, 0, 1); merger.connect(context.destination); @@ -44,39 +36,35 @@ // Schedule the disconnection of |source2| at the half of render // duration. - context.suspend(disconnectTime).then(function() { + context.suspend(disconnectTime).then(() => { 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); + const resultBuffer = await context.startRendering(); + // The entire first channel of the output should be 1. + assert_constant_value( + resultBuffer.getChannelData(0), 1, 'Channel #0 should be 1.'); + + // Calculate the first zero index in the second channel. + const channel1 = resultBuffer.getChannelData(1); + let disconnectIndex = disconnectTime * sampleRate; + disconnectIndex = renderQuantum * + Math.floor((disconnectIndex + renderQuantum - 1) / renderQuantum); - // 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; - }); + const firstZeroIndex = + channel1.findIndex(element => element === 0); - // 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()); - }); + // The second channel should contain 1, and 0 after the + // disconnection. + assert_constant_value(channel1.subarray(0, disconnectIndex), 1, + 'Channel #1 before disconnect'); + assert_constant_value(channel1.subarray(disconnectIndex), 0, + 'Channel #1 after disconnect'); - audit.run(); + assert_equals(firstZeroIndex, disconnectIndex, + 'The index of first zero in the channel #1'); + }, 'Asynchronous disconnect() correctly silences the output'); </script> </body> </html>