mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 15:49:11 +00:00
LibWeb: Validate parameters for source node start() and stop() methods
This commit is contained in:
parent
98ec1825de
commit
3261f873c5
Notes:
github-actions[bot]
2025-01-11 01:44:33 +00:00
Author: https://github.com/tcl3
Commit: 3261f873c5
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3204
6 changed files with 162 additions and 5 deletions
|
@ -35,14 +35,38 @@ void AudioScheduledSourceNode::set_onended(GC::Ptr<WebIDL::CallbackType> value)
|
|||
// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-start
|
||||
WebIDL::ExceptionOr<void> AudioScheduledSourceNode::start(double when)
|
||||
{
|
||||
(void)when;
|
||||
// 1. If this AudioScheduledSourceNode internal slot [[source started]] is true, an InvalidStateError exception MUST be thrown.
|
||||
if (source_started())
|
||||
return WebIDL::InvalidStateError::create(realm(), "AudioScheduledSourceNode source has already started"_string);
|
||||
|
||||
// 2. Check for any errors that must be thrown due to parameter constraints described below. If any exception is thrown during this step, abort those steps.
|
||||
// A RangeError exception MUST be thrown if when is negative.
|
||||
if (when < 0)
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::RangeError, "when must not be negative"sv };
|
||||
|
||||
// 3. Set the internal slot [[source started]] on this AudioScheduledSourceNode to true.
|
||||
set_source_started(true);
|
||||
|
||||
// FIXME: 4. Queue a control message to start the AudioScheduledSourceNode, including the parameter values in the message.
|
||||
// FIXME: 5. Send a control message to the associated AudioContext to start running its rendering thread only when all the following conditions are met:
|
||||
|
||||
return WebIDL::NotSupportedError::create(realm(), "FIXME: Implement AudioScheduledSourceNode::start"_string);
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-stop
|
||||
WebIDL::ExceptionOr<void> AudioScheduledSourceNode::stop(double when)
|
||||
{
|
||||
(void)when;
|
||||
// 1. If this AudioScheduledSourceNode internal slot [[source started]] is not true, an InvalidStateError exception MUST be thrown.
|
||||
if (!m_source_started)
|
||||
return WebIDL::InvalidStateError::create(realm(), "AudioScheduledSourceNode source has not been started"_string);
|
||||
|
||||
// 2. Check for any errors that must be thrown due to parameter constraints described below.
|
||||
// A RangeError exception MUST be thrown if when is negative.
|
||||
if (when < 0)
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::RangeError, "when must not be negative"sv };
|
||||
|
||||
// FIXME: 3. Queue a control message to stop the AudioScheduledSourceNode, including the parameter values in the message.
|
||||
|
||||
return WebIDL::NotSupportedError::create(realm(), "FIXME: Implement AudioScheduledSourceNode::stop"_string);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue