Commit 7022f1cd authored by Markus Handell's avatar Markus Handell Committed by Commit Bot

Add regression test for a MediaRecorder::StopRecording crash.

This change adds an additional unit test for the case encountered in
crbug.com/1040339. It's verified to crash if the fix for 1040339 is reverted.

Bug: 1040339
Change-Id: I940aef360589eb917b49e91f6eb84ad4014e0e31
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2003175Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Markus Handell <handellm@google.com>
Cr-Commit-Position: refs/heads/master@{#732456}
parent 353abff9
...@@ -323,6 +323,7 @@ jumbo_source_set("unit_tests") { ...@@ -323,6 +323,7 @@ jumbo_source_set("unit_tests") {
"mediarecorder/audio_track_recorder_unittest.cc", "mediarecorder/audio_track_recorder_unittest.cc",
"mediarecorder/fake_encoded_video_frame.h", "mediarecorder/fake_encoded_video_frame.h",
"mediarecorder/media_recorder_handler_unittest.cc", "mediarecorder/media_recorder_handler_unittest.cc",
"mediarecorder/media_recorder_unittest.cc",
"mediarecorder/track_recorder_unittest.cc", "mediarecorder/track_recorder_unittest.cc",
"mediarecorder/video_track_recorder_unittest.cc", "mediarecorder/video_track_recorder_unittest.cc",
"mediasession/media_session_test.cc", "mediasession/media_session_test.cc",
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/modules/mediarecorder/media_recorder.h"
#include <memory>
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/blink/public/web/modules/mediastream/media_stream_video_track.h"
#include "third_party/blink/public/web/web_heap.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h"
#include "third_party/blink/renderer/modules/mediastream/mock_media_stream_registry.h"
#include "third_party/blink/renderer/modules/mediastream/mock_media_stream_video_source.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_audio_source.h"
#include "third_party/blink/renderer/platform/testing/io_task_runner_testing_platform_support.h"
namespace blink {
namespace {
MediaStream* CreateMediaStream(V8TestingScope* scope) {
WebMediaStreamSource blink_source;
blink_source.Initialize("video source id", WebMediaStreamSource::kTypeVideo,
"video source name", false /* remote */);
auto native_source = std::make_unique<MockMediaStreamVideoSource>();
MockMediaStreamVideoSource* native_source_ptr = native_source.get();
blink_source.SetPlatformSource(std::move(native_source));
auto* component = MakeGarbageCollected<MediaStreamComponent>(blink_source);
component->SetPlatformTrack(std::make_unique<MediaStreamVideoTrack>(
native_source_ptr, MediaStreamVideoSource::ConstraintsOnceCallback(),
true /* enabled */));
auto* track = MakeGarbageCollected<MediaStreamTrack>(
scope->GetExecutionContext(), component);
return MediaStream::Create(scope->GetExecutionContext(),
MediaStreamTrackVector{track});
}
} // namespace
// This is a regression test for crbug.com/1999203
TEST(MediaRecorderTest,
AcceptsAllTracksEndedEventWhenExecutionContextDestroyed) {
ScopedTestingPlatformSupport<IOTaskRunnerTestingPlatformSupport> platform;
{
V8TestingScope scope;
MediaStream* stream = CreateMediaStream(&scope);
MediaRecorder* recorder = MakeGarbageCollected<MediaRecorder>(
scope.GetExecutionContext(), stream, MediaRecorderOptions::Create(),
scope.GetExceptionState());
recorder->start(scope.GetExceptionState());
for (const auto& track : stream->getTracks())
track->Component()->GetPlatformTrack()->Stop();
}
platform->RunUntilIdle();
WebHeap::CollectAllGarbageForTesting();
}
} // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment