tor-browser

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

commit c39ee425534320960e795f6b125967448ec9a079
parent 1eebaa043bbf324327092641e2a4cdb68f6d0836
Author: punithbnayak <punithbnayak@chromium.org>
Date:   Fri, 14 Nov 2025 10:22:48 +0000

Bug 1999767 [wpt PR 56003] - [webaudio-testharness] Migrate audioworkletnode-channel-count.https.html, a=testonly

Automatic update from web-platform-tests
[webaudio-testharness] Migrate audioworkletnode-channel-count.https.html

Convert audioworkletnode-channel-count.https.html from the legacy
audit.js runner to pure testharness.js

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

--

wpt-commits: b70ea7252a52acfedb81ae66e6f9327ce875211c
wpt-pr: 56003

Diffstat:
Mtesting/web-platform/tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-channel-count.https.html | 100++++++++++++++++++++++++++++++++++++++++---------------------------------------
1 file changed, 51 insertions(+), 49 deletions(-)

diff --git a/testing/web-platform/tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-channel-count.https.html b/testing/web-platform/tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-channel-count.https.html @@ -6,72 +6,74 @@ </title> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> - <script src="/webaudio/resources/audit.js"></script> <script src="/webaudio/resources/audit-util.js"></script> </head> <body> - <script id="layout-test-code"> - let audit = Audit.createTaskRunner(); - + <script> // Arbitrary numbers used to align the test with render quantum boundary. - let sampleRate = RENDER_QUANTUM_FRAMES * 100; - let renderLength = RENDER_QUANTUM_FRAMES * 2; - let context; - - let filePath = 'processors/gain-processor.js'; + const sampleRate = RENDER_QUANTUM_FRAMES * 100; + const renderLength = RENDER_QUANTUM_FRAMES * 2; + const filePath = 'processors/gain-processor.js'; - let testChannelValues = [1, 2, 3]; + const testChannelValues = [1, 2, 3]; - // Creates a 3-channel buffer and play with BufferSourceNode. The source - // goes through a bypass AudioWorkletNode (gain value of 1). - audit.define('setup-buffer-and-worklet', (task, should) => { - context = new OfflineAudioContext(testChannelValues.length, - renderLength, - sampleRate); + // Creates a 3-channel source and play with ConstantSourceNode. + // The source goes through a bypass AudioWorkletNode (gain value of 1). + // Verifies if the rendered buffer has all zero for the first half + // (before 128 samples) and the expected values for the second half. + promise_test(async () => { + const context = new OfflineAudioContext( + testChannelValues.length, + renderLength, + sampleRate); // Explicitly sets the destination channelCountMode and // channelInterpretation to make sure the result does no mixing. - context.channeCountMode = 'explicit'; + context.channelCountMode = 'explicit'; context.channelInterpretation = 'discrete'; - context.audioWorklet.addModule(filePath).then(() => { - let testBuffer = createConstantBuffer(context, 1, testChannelValues); - let sourceNode = new AudioBufferSourceNode(context); - let gainWorkletNode = new AudioWorkletNode(context, 'gain'); + await context.audioWorklet.addModule(filePath); - gainWorkletNode.parameters.get('gain').value = 1.0; - sourceNode.connect(gainWorkletNode).connect(context.destination); + const gainWorkletNode = new AudioWorkletNode(context, 'gain'); + gainWorkletNode.parameters.get('gain').value = 1.0; - // Suspend the context at 128 sample frames and play the source with - // the assigned buffer. - context.suspend(RENDER_QUANTUM_FRAMES/sampleRate).then(() => { - sourceNode.buffer = testBuffer; - sourceNode.loop = true; - sourceNode.start(); - context.resume(); - }); - task.done(); + // Create a ChannelMergerNode to combine multiple ConstantSourceNodes + const merger = new ChannelMergerNode( + context, {numberOfInputs: testChannelValues.length}); + merger.connect(gainWorkletNode); + gainWorkletNode.connect(context.destination); + + // Create a ConstantSourceNode for each channel with its + // corresponding value + const constantSources = testChannelValues.map((value, index) => { + const constantSource = + new ConstantSourceNode(context, {offset: value}); + constantSource.connect(merger, 0, index); + return constantSource; }); - }); - // Verifies if the rendered buffer has all zero for the first half (before - // 128 samples) and the expected values for the second half. - audit.define('verify-rendered-buffer', (task, should) => { - context.startRendering().then(renderedBuffer => { - testChannelValues.forEach((value, index) => { - let channelData = renderedBuffer.getChannelData(index); - should(channelData.subarray(0, RENDER_QUANTUM_FRAMES), - 'First half of Channel #' + index) - .beConstantValueOf(0); - should(channelData.subarray(RENDER_QUANTUM_FRAMES, renderLength), - 'Second half of Channel #' + index) - .beConstantValueOf(value); - }); - task.done(); - }); + // Suspend the context at 128 sample frames and start the sources. + context.suspend(RENDER_QUANTUM_FRAMES/sampleRate).then(() => { + constantSources.forEach(source => source.start()); + context.resume(); }); - audit.run(); + const renderedBuffer = await context.startRendering(); + + testChannelValues.forEach((value, index) => { + const channelData = renderedBuffer.getChannelData(index); + + assert_constant_value( + channelData.subarray(0, RENDER_QUANTUM_FRAMES), + 0, + 'First half of Channel #' + index); + + assert_constant_value( + channelData.subarray(RENDER_QUANTUM_FRAMES, renderLength), + value, + 'Second half of Channel #' + index); + }); + }, 'setup-buffer-and-worklet-verify-rendered-buffer'); </script> </body> </html>