mirror of
https://github.com/servo/servo.git
synced 2025-08-15 18:35:33 +01:00
Update web-platform-tests to revision e87f38097902e16348d4e17f4fe3bc2d0112bff1
This commit is contained in:
parent
2f8fa32e91
commit
db5631a086
381 changed files with 11610 additions and 4232 deletions
|
@ -0,0 +1,100 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
Test AudioWorkletNode's Disconnected Input Array Length
|
||||
</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();
|
||||
|
||||
// Arbitrary numbers used to align the test with render quantum boundary.
|
||||
// The sample rate is a power of two to eliminate roundoff in computing
|
||||
// the suspend time needed for the test.
|
||||
let sampleRate = 16384;
|
||||
let renderLength = 8 * RENDER_QUANTUM_FRAMES;
|
||||
let context;
|
||||
|
||||
let filePath = 'processors/input-length-processor.js';
|
||||
|
||||
let 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(
|
||||
{
|
||||
label: 'test',
|
||||
description:
|
||||
'Input array length should be zero for disconnected input'
|
||||
},
|
||||
(task, should) => {
|
||||
context = new OfflineAudioContext({
|
||||
numberOfChannels: 1,
|
||||
length: renderLength,
|
||||
sampleRate: sampleRate
|
||||
});
|
||||
|
||||
context.audioWorklet.addModule(filePath).then(() => {
|
||||
let sourceNode = new ConstantSourceNode(context);
|
||||
let workletNode =
|
||||
new AudioWorkletNode(context, 'input-length-processor');
|
||||
|
||||
workletNode.connect(context.destination);
|
||||
|
||||
// Connect the source now.
|
||||
let connectFrame = RENDER_QUANTUM_FRAMES;
|
||||
|
||||
context.suspend(connectFrame / sampleRate)
|
||||
.then(() => {
|
||||
sourceNode.connect(workletNode);
|
||||
})
|
||||
.then(() => context.resume());
|
||||
;
|
||||
|
||||
// Then disconnect the source after a few renders
|
||||
let disconnectFrame = 3 * RENDER_QUANTUM_FRAMES;
|
||||
context.suspend(disconnectFrame / sampleRate)
|
||||
.then(() => {
|
||||
sourceNode.disconnect(workletNode);
|
||||
})
|
||||
.then(() => context.resume());
|
||||
|
||||
sourceNode.start();
|
||||
context.startRendering()
|
||||
.then(resultBuffer => {
|
||||
let data = resultBuffer.getChannelData(0);
|
||||
|
||||
should(
|
||||
data.slice(0, connectFrame),
|
||||
'Before connecting the source: Input array length')
|
||||
.beConstantValueOf(0);
|
||||
|
||||
// Find where the output is no longer 0.
|
||||
let nonZeroIndex = data.findIndex(x => x > 0);
|
||||
should(nonZeroIndex, 'First non-zero output')
|
||||
.beEqualTo(connectFrame);
|
||||
|
||||
should(
|
||||
data.slice(
|
||||
nonZeroIndex,
|
||||
nonZeroIndex + (disconnectFrame - connectFrame)),
|
||||
'While source is connected: Input array length')
|
||||
.beConstantValueOf(RENDER_QUANTUM_FRAMES);
|
||||
should(
|
||||
data.slice(disconnectFrame),
|
||||
'After disconnecting the source: Input array length')
|
||||
.beConstantValueOf(0);
|
||||
})
|
||||
.then(() => task.done());
|
||||
});
|
||||
});
|
||||
|
||||
audit.run();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* @class InputLengthProcessor
|
||||
* @extends AudioWorkletProcessor
|
||||
*
|
||||
* This processor class just sets the output to the length of the
|
||||
* input array for verifying that the input length changes when the
|
||||
* input is disconnected.
|
||||
*/
|
||||
class InputLengthProcessor extends AudioWorkletProcessor {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
process(inputs, outputs, parameters) {
|
||||
let input = inputs[0];
|
||||
let output = outputs[0];
|
||||
|
||||
// Set output channel to the length of the input channel array.
|
||||
output[0].fill(input[0].length);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
registerProcessor('input-length-processor', InputLengthProcessor);
|
Loading…
Add table
Add a link
Reference in a new issue