commit e37de26b8a46e8cfdd6d51b83a4d5bf5d214edcb
parent 97a146b007d67075b650fbc9519d4a44fd92c7a6
Author: Saqlain <2mesaqlain@gmail.com>
Date: Thu, 9 Oct 2025 16:28:45 +0000
Bug 1991167 [wpt PR 55109] - [webaudio-testharness] Migrate k-rate-audioworklet.https.html, a=testonly
Automatic update from web-platform-tests
[webaudio-testharness] Migrate k-rate-audioworklet.https.html
Convert k-rate-audioworklet.https.html from the legacy audit.js runner
to pure testharness.js
Bug: 396477778
Change-Id: Iaf43d4095ad9db98ed84338ff4ed239817e1ffb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6974138
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@{#1521540}
--
wpt-commits: 7f4a3e1ae630cfebf71480e46194ed9c0d7190d5
wpt-pr: 55109
Diffstat:
1 file changed, 19 insertions(+), 37 deletions(-)
diff --git a/testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-audioworklet.https.html b/testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-audioworklet.https.html
@@ -1,17 +1,13 @@
-<!doctype html>
+<!DOCTYPE html>
<html>
<head>
<title>Test k-rate AudioParam of 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';
@@ -19,8 +15,7 @@
// Context for testing
let context;
- audit.define('Create Test Worklet', (task, should) => {
-
+ promise_test(async () => {
// Arbitrary sample rate and duration.
const sampleRate = 8000;
@@ -30,24 +25,16 @@
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());
- });
-
- audit.define('AudioWorklet k-rate AudioParam', (task, should) => {
- let src = new ConstantSourceNode(context);
-
- let kRateNode = new AudioWorkletNode(context, 'gain');
+ await context.audioWorklet.addModule(filePath);
+ 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';
// Automate the gain
@@ -57,23 +44,18 @@
src.start();
- context.startRendering()
- .then(audioBuffer => {
- let output = audioBuffer.getChannelData(0);
-
- // 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]);
- }
- })
- .then(() => task.done());
- });
-
- audit.run();
+ const audioBuffer = await context.startRendering();
+ const output = audioBuffer.getChannelData(0);
+
+ // Verify that the output from the worklet is step-wise
+ // constant.
+ for (let k = 0; k < output.length; k += 128) {
+ assert_array_equals(
+ output.slice(k, k + 128),
+ new Float32Array(128).fill(output[k]),
+ `k-rate output [${k}: ${k + 127}]`);
+ }
+ }, 'AudioWorklet k-rate AudioParam');
</script>
</body>
</html>