commit ae90a77dfc1f44e1903274deb5ce401db745a7c3
parent 462419f6f65aa8a0af75c08e50748c1a588b3cf2
Author: Saqlain <2mesaqlain@gmail.com>
Date: Wed, 15 Oct 2025 08:23:58 +0000
Bug 1993637 [wpt PR 55337] - [webaudio-testharness] Migrate k-rate-audioworklet-connections.html, a=testonly
Automatic update from web-platform-tests
[webaudio-testharness] Migrate k-rate-audioworklet-connections.html
Convert k-rate-audioworklet-connections.https.html from the legacy
audit.js runner to pure testharness.js
Bug: 396477778
Change-Id: I5813a663aab4a35ce12bb2105ea83929c7df3fd9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7003268
Reviewed-by: Michael Wilson <mjwilson@chromium.org>
Reviewed-by: Hongchan Choi <hongchan@chromium.org>
Commit-Queue: Saqlain <2mesaqlain@gmail.com>
Cr-Commit-Position: refs/heads/main@{#1527762}
--
wpt-commits: bcc23b4109f81cb18c6a1cc906c0d7c54efc246b
wpt-pr: 55337
Diffstat:
1 file changed, 21 insertions(+), 30 deletions(-)
diff --git a/testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-audioworklet-connections.https.html b/testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-audioworklet-connections.https.html
@@ -1,54 +1,44 @@
-<!doctype html>
+<!DOCTYPE html>
<html>
<head>
- <title>Test k-rate AudioParams with inputs for AudioWorkletNode</title>
+ <title>
+ Test k-rate AudioParams with inputs for AudioWorkletNode
+ </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>
- const audit = Audit.createTaskRunner();
-
// Use the worklet gain node to test k-rate parameters.
const filePath =
'../the-audioworklet-interface/processors/gain-processor.js';
- // Context for testing
- let context;
-
- audit.define('Create Test Worklet', (task, should) => {
+ promise_test(async () => {
// Arbitrary sample rate and duration.
const sampleRate = 8000;
// Only new a few render quanta to verify things are working.
const testDuration = 4 * 128 / sampleRate;
- context = new OfflineAudioContext({
+ const context = new OfflineAudioContext({
numberOfChannels: 3,
sampleRate: sampleRate,
- length: testDuration * sampleRate
+ length: testDuration * sampleRate,
});
- should(
- context.audioWorklet.addModule(filePath),
- 'Construction of AudioWorklet')
- .beResolved()
- .then(() => task.done());
- });
+ await context.audioWorklet.addModule(filePath);
- audit.define('AudioWorklet k-rate AudioParam', async (task, should) => {
- let src = new ConstantSourceNode(context);
- let kRateNode = new AudioWorkletNode(context, 'gain');
+ const src = new ConstantSourceNode(context);
+ const kRateNode = new AudioWorkletNode(context, 'gain');
src.connect(kRateNode).connect(context.destination);
- let kRateParam = kRateNode.parameters.get('gain');
+ const kRateParam = kRateNode.parameters.get('gain');
kRateParam.automationRate = 'k-rate';
kRateParam.value = 0;
- let mod = new ConstantSourceNode(context);
+ const mod = new ConstantSourceNode(context);
mod.offset.setValueAtTime(0, 0);
mod.offset.linearRampToValueAtTime(
10, context.length / context.sampleRate);
@@ -58,20 +48,21 @@
src.start();
const audioBuffer = await context.startRendering();
- let output = audioBuffer.getChannelData(0);
+ const output = audioBuffer.getChannelData(0);
// Verify that the output isn't constantly zero.
- should(output, 'output').notBeConstantValueOf(0);
+ const allZero = !output.some((value) => value !== 0);
+ assert_false(allZero, `output should not be all zeros`);
+
// Verify that the output from the worklet is step-wise
// constant.
for (let k = 0; k < output.length; k += 128) {
- should(output.slice(k, k + 128), ` k-rate output [${k}: ${k + 127}]`)
- .beConstantValueOf(output[k]);
+ const slice = output.slice(k, k + 128);
+ const expected = new Float32Array(slice.length).fill(slice[0]);
+ assert_array_equals(
+ slice, expected, `k-rate output [${k}: ${k + 127}]`);
}
- task.done();
- });
-
- audit.run();
+ }, 'AudioWorklet k-rate AudioParam');
</script>
</body>
</html>