blob: 33627204a6f538eba77bd8346952404814e4affa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
<!doctype html>
<html>
<head>
<title>
Test given arrays within AudioWorkletProcessor.process() method
</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/webaudio/resources/audit.js"></script>
</head>
<body>
<script>
const audit = Audit.createTaskRunner();
const filePath = 'processors/array-check-processor.js';
const context = new AudioContext();
// Test if the incoming arrays are frozen as expected.
audit.define('check-frozen-array', (task, should) => {
context.audioWorklet.addModule(filePath).then(() => {
const workletNode =
new AudioWorkletNode(context, 'array-frozen-processor');
workletNode.port.onmessage = (message) => {
const actual = message.data;
should(actual.isInputFrozen, '|inputs| is frozen').beTrue();
should(actual.isOutputFrozen, '|outputs| is frozen').beTrue();
task.done();
};
});
});
// The incoming arrays should not be transferred, but the associated
// ArrayBuffers can be transferred. See the `array-transfer-processor`
// definition for the details.
audit.define('transfer-frozen-array', (task, should) => {
const sourceNode = new ConstantSourceNode(context);
const workletNode =
new AudioWorkletNode(context, 'array-transfer-processor');
workletNode.port.onmessage = (message) => {
const actual = message.data;
if (actual.type === 'assertion')
should(actual.success, actual.message).beTrue();
if (actual.done)
task.done();
};
sourceNode.connect(workletNode);
sourceNode.start();
});
audit.run();
</script>
</body>
</html>
|