diff --git a/components/script/dom/offlineaudiocontext.rs b/components/script/dom/offlineaudiocontext.rs index 899574e35e4..32aaa926ec9 100644 --- a/components/script/dom/offlineaudiocontext.rs +++ b/components/script/dom/offlineaudiocontext.rs @@ -64,21 +64,33 @@ impl OfflineAudioContext { channel_count: u32, length: u32, sample_rate: f32, - ) -> DomRoot { + ) -> Fallible> { + 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); - reflect_dom_object(Box::new(context), window, OfflineAudioContextBinding::Wrap) + Ok(reflect_dom_object( + Box::new(context), + window, + OfflineAudioContextBinding::Wrap, + )) } pub fn Constructor( window: &Window, options: &OfflineAudioContextOptions, ) -> Fallible> { - Ok(OfflineAudioContext::new( + OfflineAudioContext::new( window, options.numberOfChannels, options.length, *options.sampleRate, - )) + ) } pub fn Constructor_( @@ -87,21 +99,7 @@ impl OfflineAudioContext { length: u32, sample_rate: Finite, ) -> Fallible> { - if number_of_channels > MAX_CHANNEL_COUNT || - 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, - )) + OfflineAudioContext::new(window, number_of_channels, length, *sample_rate) } } diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-offlineaudiocontext-interface/ctor-offlineaudiocontext.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-offlineaudiocontext-interface/ctor-offlineaudiocontext.html.ini deleted file mode 100644 index 892336f1c9a..00000000000 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-offlineaudiocontext-interface/ctor-offlineaudiocontext.html.ini +++ /dev/null @@ -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 -