LibWeb: Implement OscillatorNode.type

This is a simple getter and setter of the OscillatorType enum, with
error checking to not allow 'custom', as that should only be changed
through 'setPeriodicWave()'.
This commit is contained in:
Shannon Booth 2024-05-01 20:53:39 +12:00 committed by Andreas Kling
commit 099c9e4a7e
Notes: sideshowbarker 2024-07-16 20:08:14 +09:00
5 changed files with 61 additions and 2 deletions

View file

@ -15,5 +15,22 @@
// Context getter
println(`context: '${oscillator.context}, is same as original: ${audioContext === oscillator.context}`);
// Invalid type in constructor
try {
new OscillatorNode(audioContext, { type: 'custom' });
} catch (e) {
println(`Error creating node: '${e}'`);
}
// Type attribute
println(`oscillator node type: '${oscillator.type}'`);
try {
oscillator.type = 'custom';
} catch (e) {
println(`Error: '${e}', type is: ${oscillator.type}`);
}
oscillator.type = 'triangle';
println(`oscillator node type: '${oscillator.type}'`);
});
</script>