Bug 919051 - Media Recording - memory leak when record a media stream without any tracks. r=roc, r=jsmith

This commit is contained in:
Randy Lin 2013-09-27 17:56:16 +08:00
Родитель 033860ea1f
Коммит fc76c58ecb
3 изменённых файлов: 50 добавлений и 5 удалений

Просмотреть файл

@ -183,6 +183,12 @@ public:
if (!mReadThread) {
nsresult rv = NS_NewNamedThread("Media Encoder", getter_AddRefs(mReadThread));
if (NS_FAILED(rv)) {
if (mInputPort.get()) {
mInputPort->Destroy();
}
if (mTrackUnionStream.get()) {
mTrackUnionStream->Destroy();
}
mRecorder->NotifyError(rv);
return;
}
@ -363,6 +369,16 @@ MediaRecorder::Start(const Optional<int32_t>& aTimeSlice, ErrorResult& aResult)
return;
}
if (!mStream->GetPrincipal()) {
aResult.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
if (!CheckPrincipal()) {
aResult.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
int32_t timeSlice = 0;
if (aTimeSlice.WasPassed()) {
if (aTimeSlice.Value() < 0) {
@ -373,11 +389,6 @@ MediaRecorder::Start(const Optional<int32_t>& aTimeSlice, ErrorResult& aResult)
timeSlice = aTimeSlice.Value();
}
if (!CheckPrincipal()) {
aResult.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
mState = RecordingState::Recording;
// Start a session
mSession = new Session(this, timeSlice);

Просмотреть файл

@ -121,6 +121,7 @@ MOCHITEST_FILES = \
test_mediarecorder_record_timeslice.html \
test_mediarecorder_record_audiocontext.html \
test_mediarecorder_record_stopms.html \
test_mediarecorder_record_nosrc.html \
test_mozHasAudio.html \
test_source_media.html \
test_autoplay_contentEditable.html \

Просмотреть файл

@ -0,0 +1,33 @@
<html>
<head>
<title>Bug 919051 - Media Recording - memory leak when record a media stream without any tracks</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="manifest.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=919051">Mozill
a Bug 919051</a>
<pre id="test">
<script class="testbody" type="text/javascript">
function startTest() {
var mediastream = document.createElement('video').mozCaptureStream();
var mr = new MediaRecorder(mediastream);
info('create MediaRecorder');
try {
mr.start();
ok(false, 'should get exception');
} catch(e) {
is(e.name, 'InvalidStateError', "get correct exception");
}
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
startTest();
</script>
</head>
</html>