mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Check constraints in both overloaded OfflineAudioContext constructors
This commit is contained in:
parent
d60b14bed5
commit
13b5774017
2 changed files with 17 additions and 35 deletions
|
@ -64,21 +64,33 @@ impl OfflineAudioContext {
|
||||||
channel_count: u32,
|
channel_count: u32,
|
||||||
length: u32,
|
length: u32,
|
||||||
sample_rate: f32,
|
sample_rate: f32,
|
||||||
) -> DomRoot<OfflineAudioContext> {
|
) -> Fallible<DomRoot<OfflineAudioContext>> {
|
||||||
|
if channel_count > MAX_CHANNEL_COUNT ||
|
||||||
|
channel_count <= 0 ||
|
||||||
|
length <= 0 ||
|
||||||
|
sample_rate < MIN_SAMPLE_RATE ||
|
||||||
|
sample_rate > MAX_SAMPLE_RATE
|
||||||
|
{
|
||||||
|
return Err(Error::NotSupported);
|
||||||
|
}
|
||||||
let context = OfflineAudioContext::new_inherited(channel_count, length, sample_rate);
|
let context = OfflineAudioContext::new_inherited(channel_count, length, sample_rate);
|
||||||
reflect_dom_object(Box::new(context), window, OfflineAudioContextBinding::Wrap)
|
Ok(reflect_dom_object(
|
||||||
|
Box::new(context),
|
||||||
|
window,
|
||||||
|
OfflineAudioContextBinding::Wrap,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
options: &OfflineAudioContextOptions,
|
options: &OfflineAudioContextOptions,
|
||||||
) -> Fallible<DomRoot<OfflineAudioContext>> {
|
) -> Fallible<DomRoot<OfflineAudioContext>> {
|
||||||
Ok(OfflineAudioContext::new(
|
OfflineAudioContext::new(
|
||||||
window,
|
window,
|
||||||
options.numberOfChannels,
|
options.numberOfChannels,
|
||||||
options.length,
|
options.length,
|
||||||
*options.sampleRate,
|
*options.sampleRate,
|
||||||
))
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor_(
|
pub fn Constructor_(
|
||||||
|
@ -87,21 +99,7 @@ impl OfflineAudioContext {
|
||||||
length: u32,
|
length: u32,
|
||||||
sample_rate: Finite<f32>,
|
sample_rate: Finite<f32>,
|
||||||
) -> Fallible<DomRoot<OfflineAudioContext>> {
|
) -> Fallible<DomRoot<OfflineAudioContext>> {
|
||||||
if number_of_channels > MAX_CHANNEL_COUNT ||
|
OfflineAudioContext::new(window, number_of_channels, length, *sample_rate)
|
||||||
number_of_channels <= 0 ||
|
|
||||||
length <= 0 ||
|
|
||||||
*sample_rate < MIN_SAMPLE_RATE ||
|
|
||||||
*sample_rate > MAX_SAMPLE_RATE
|
|
||||||
{
|
|
||||||
return Err(Error::NotSupported);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(OfflineAudioContext::new(
|
|
||||||
window,
|
|
||||||
number_of_channels,
|
|
||||||
length,
|
|
||||||
*sample_rate,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
[ctor-offlineaudiocontext.html]
|
|
||||||
[# AUDIT TASK RUNNER FINISHED: 1 out of 4 tasks were failed.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[X new OfflineAudioContext({"length":1,"sampleRate":1}) did not throw an exception.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[X new OfflineAudioContext({"length":0,"sampleRate":8000}) did not throw an exception.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[< [options-2\] 3 out of 3 assertions were failed.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[X new OfflineAudioContext({"length":42,"sampleRate":8000,"numberOfChannels":33}) did not throw an exception.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue