LibWeb: Add ChannelSplitterNode interface

This commit is contained in:
Tim Ledbetter 2025-01-01 22:00:52 +00:00 committed by Tim Ledbetter
commit e564d25ffb
Notes: github-actions[bot] 2025-01-02 11:40:31 +00:00
9 changed files with 315 additions and 1 deletions

View file

@ -57,6 +57,7 @@ CanvasGradient
CanvasPattern
CanvasRenderingContext2D
ChannelMergerNode
ChannelSplitterNode
CharacterData
Clipboard
ClipboardEvent

View file

@ -0,0 +1,52 @@
Harness status: OK
Found 47 tests
47 Pass
Pass # AUDIT TASK RUNNER STARTED.
Pass Executing "initialize"
Pass Executing "invalid constructor"
Pass Executing "default constructor"
Pass Executing "test AudioNodeOptions"
Pass Executing "constructor options"
Pass Audit report
Pass > [initialize]
Pass context = new OfflineAudioContext(...) did not throw an exception.
Pass < [initialize] All assertions passed. (total 1 assertions)
Pass > [invalid constructor]
Pass new ChannelSplitterNode() threw TypeError: "ChannelSplitterNode() needs one argument".
Pass new ChannelSplitterNode(1) threw TypeError: "Not an object of type BaseAudioContext".
Pass new ChannelSplitterNode(context, 42) threw TypeError: "Not an object of type ChannelSplitterOptions".
Pass < [invalid constructor] All assertions passed. (total 3 assertions)
Pass > [default constructor]
Pass node0 = new ChannelSplitterNode(context) did not throw an exception.
Pass node0 instanceof ChannelSplitterNode is equal to true.
Pass node0.numberOfInputs is equal to 1.
Pass node0.numberOfOutputs is equal to 6.
Pass node0.channelCount is equal to 6.
Pass node0.channelCountMode is equal to explicit.
Pass node0.channelInterpretation is equal to discrete.
Pass < [default constructor] All assertions passed. (total 7 assertions)
Pass > [test AudioNodeOptions]
Pass new ChannelSplitterNode(c, {channelCount: 6}) did not throw an exception.
Pass node.channelCount is equal to 6.
Pass new ChannelSplitterNode(c, {channelCount: 7}) threw InvalidStateError: "Channel count must be equal to number of outputs".
Pass (new ChannelSplitterNode(c, {channelCount: 6})).channelCount = 6 did not throw an exception.
Pass new ChannelSplitterNode(c, {channelCountMode: "explicit"} did not throw an exception.
Pass node.channelCountMode is equal to explicit.
Pass new ChannelSplitterNode(c, {channelCountMode: "max"}) threw InvalidStateError: "Channel count mode must be 'explicit'".
Pass new ChannelSplitterNode(c, {channelCountMode: "clamped-max"}) threw InvalidStateError: "Channel count mode must be 'explicit'".
Pass (new ChannelSplitterNode(c, {channelCountMode: "explicit"})).channelCountMode = "explicit" did not throw an exception.
Pass new ChannelSplitterNode(c, {channelInterpretation: "speakers"}) threw InvalidStateError: "Channel interpretation must be 'discrete'".
Pass (new ChannelSplitterNode(c, {channelInterpretation: "discrete"})).channelInterpretation = "discrete" did not throw an exception.
Pass < [test AudioNodeOptions] All assertions passed. (total 11 assertions)
Pass > [constructor options]
Pass node1 = new ChannelSplitterNode(context, {"numberOfInputs":3,"numberOfOutputs":9,"channelInterpretation":"discrete"}) did not throw an exception.
Pass node1.numberOfInputs is equal to 1.
Pass node1.numberOfOutputs is equal to 9.
Pass node1.channelInterpretation is equal to discrete.
Pass new ChannelSplitterNode(c, {"numberOfOutputs":99}) threw IndexSizeError: "Invalid number of outputs".
Pass new ChannelSplitterNode(c, {"channelCount":3}) threw InvalidStateError: "Channel count must be equal to number of outputs".
Pass new ChannelSplitterNode(c, {"channelCountMode":"max"}) threw InvalidStateError: "Channel count mode must be 'explicit'".
Pass < [constructor options] All assertions passed. (total 7 assertions)
Pass # AUDIT TASK RUNNER FINISHED: 5 tasks ran successfully.

View file

@ -0,0 +1,115 @@
<!DOCTYPE html>
<html>
<head>
<title>
Test Constructor: ChannelSplitter
</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>
<script src="../../../webaudio/resources/audionodeoptions.js"></script>
</head>
<body>
<script id="layout-test-code">
let context;
let audit = Audit.createTaskRunner();
audit.define('initialize', (task, should) => {
context = initializeContext(should);
task.done();
});
audit.define('invalid constructor', (task, should) => {
testInvalidConstructor(should, 'ChannelSplitterNode', context);
task.done();
});
audit.define('default constructor', (task, should) => {
testDefaultConstructor(should, 'ChannelSplitterNode', context, {
prefix: 'node0',
numberOfInputs: 1,
numberOfOutputs: 6,
channelCount: 6,
channelCountMode: 'explicit',
channelInterpretation: 'discrete'
});
task.done();
});
audit.define('test AudioNodeOptions', (task, should) => {
testAudioNodeOptions(should, context, 'ChannelSplitterNode', {
channelCount: {
value: 6,
isFixed: true,
exceptionType: 'InvalidStateError'
},
channelCountMode: {
value: 'explicit',
isFixed: true,
exceptionType: 'InvalidStateError'
},
channelInterpretation: {
value: 'discrete',
isFixed: true,
exceptionType: 'InvalidStateError'
},
});
task.done();
});
audit.define('constructor options', (task, should) => {
let node;
let options = {
numberOfInputs: 3,
numberOfOutputs: 9,
channelInterpretation: 'discrete'
};
should(
() => {
node = new ChannelSplitterNode(context, options);
},
'node1 = new ChannelSplitterNode(context, ' +
JSON.stringify(options) + ')')
.notThrow();
should(node.numberOfInputs, 'node1.numberOfInputs').beEqualTo(1);
should(node.numberOfOutputs, 'node1.numberOfOutputs')
.beEqualTo(options.numberOfOutputs);
should(node.channelInterpretation, 'node1.channelInterpretation')
.beEqualTo(options.channelInterpretation);
options = {numberOfOutputs: 99};
should(
() => {
node = new ChannelSplitterNode(context, options);
},
'new ChannelSplitterNode(c, ' + JSON.stringify(options) + ')')
.throw(DOMException, 'IndexSizeError');
options = {channelCount: 3};
should(
() => {
node = new ChannelSplitterNode(context, options);
},
'new ChannelSplitterNode(c, ' + JSON.stringify(options) + ')')
.throw(DOMException, 'InvalidStateError');
options = {channelCountMode: 'max'};
should(
() => {
node = new ChannelSplitterNode(context, options);
},
'new ChannelSplitterNode(c, ' + JSON.stringify(options) + ')')
.throw(DOMException, 'InvalidStateError');
task.done();
});
audit.run();
</script>
</body>
</html>