summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/webcodecs/audio_decoder_fuzzer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/modules/webcodecs/audio_decoder_fuzzer.cc')
-rw-r--r--chromium/third_party/blink/renderer/modules/webcodecs/audio_decoder_fuzzer.cc62
1 files changed, 32 insertions, 30 deletions
diff --git a/chromium/third_party/blink/renderer/modules/webcodecs/audio_decoder_fuzzer.cc b/chromium/third_party/blink/renderer/modules/webcodecs/audio_decoder_fuzzer.cc
index b093c5d5abd..1bbb97b7656 100644
--- a/chromium/third_party/blink/renderer/modules/webcodecs/audio_decoder_fuzzer.cc
+++ b/chromium/third_party/blink/renderer/modules/webcodecs/audio_decoder_fuzzer.cc
@@ -5,10 +5,10 @@
#include "base/run_loop.h"
#include "testing/libfuzzer/proto/lpm_interface.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_audio_decoder_config.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_audio_decoder_init.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_audio_frame_output_callback.h"
-#include "third_party/blink/renderer/bindings/modules/v8/v8_encoded_audio_config.h"
-#include "third_party/blink/renderer/bindings/modules/v8/v8_web_codecs_error_callback.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_webcodecs_error_callback.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/testing/dummy_page_holder.h"
@@ -70,36 +70,38 @@ DEFINE_TEXT_PROTO_FUZZER(
Persistent<AudioDecoder> audio_decoder = AudioDecoder::Create(
script_state, audio_decoder_init, IGNORE_EXCEPTION_FOR_TESTING);
- for (auto& invocation : proto.invocations()) {
- switch (invocation.Api_case()) {
- case wc_fuzzer::AudioDecoderApiInvocation::kConfigure:
- audio_decoder->configure(
- MakeAudioDecoderConfig(invocation.configure()),
- IGNORE_EXCEPTION_FOR_TESTING);
- break;
- case wc_fuzzer::AudioDecoderApiInvocation::kDecode:
- audio_decoder->decode(
- MakeEncodedAudioChunk(invocation.decode().chunk()),
- IGNORE_EXCEPTION_FOR_TESTING);
- break;
- case wc_fuzzer::AudioDecoderApiInvocation::kFlush: {
- // TODO(https://crbug.com/1119253): Fuzz whether to await resolution
- // of the flush promise.
- audio_decoder->flush(IGNORE_EXCEPTION_FOR_TESTING);
- break;
+ if (audio_decoder) {
+ for (auto& invocation : proto.invocations()) {
+ switch (invocation.Api_case()) {
+ case wc_fuzzer::AudioDecoderApiInvocation::kConfigure:
+ audio_decoder->configure(
+ MakeAudioDecoderConfig(invocation.configure()),
+ IGNORE_EXCEPTION_FOR_TESTING);
+ break;
+ case wc_fuzzer::AudioDecoderApiInvocation::kDecode:
+ audio_decoder->decode(
+ MakeEncodedAudioChunk(invocation.decode().chunk()),
+ IGNORE_EXCEPTION_FOR_TESTING);
+ break;
+ case wc_fuzzer::AudioDecoderApiInvocation::kFlush: {
+ // TODO(https://crbug.com/1119253): Fuzz whether to await resolution
+ // of the flush promise.
+ audio_decoder->flush(IGNORE_EXCEPTION_FOR_TESTING);
+ break;
+ }
+ case wc_fuzzer::AudioDecoderApiInvocation::kReset:
+ audio_decoder->reset(IGNORE_EXCEPTION_FOR_TESTING);
+ break;
+ case wc_fuzzer::AudioDecoderApiInvocation::kClose:
+ audio_decoder->close(IGNORE_EXCEPTION_FOR_TESTING);
+ break;
+ case wc_fuzzer::AudioDecoderApiInvocation::API_NOT_SET:
+ break;
}
- case wc_fuzzer::AudioDecoderApiInvocation::kReset:
- audio_decoder->reset(IGNORE_EXCEPTION_FOR_TESTING);
- break;
- case wc_fuzzer::AudioDecoderApiInvocation::kClose:
- audio_decoder->close(IGNORE_EXCEPTION_FOR_TESTING);
- break;
- case wc_fuzzer::AudioDecoderApiInvocation::API_NOT_SET:
- break;
- }
- // Give other tasks a chance to run (e.g. calling our output callback).
- base::RunLoop().RunUntilIdle();
+ // Give other tasks a chance to run (e.g. calling our output callback).
+ base::RunLoop().RunUntilIdle();
+ }
}
}