Bug 1496383 - Fix state error cases of MediaRecorder to match the W3C spec r=jya
authorBumsik Kim <k.bumsik@gmail.com>
Mon, 08 Oct 2018 09:06:07 +0000
changeset 495859 a3a767ad55fbf01762d41f7e8bff91188e736daf
parent 495858 a9db3033d9cbf95c87e8c26c361ffe558ef6e3a9
child 495872 a9616aaeff87448588d57c295e16eb4caec420fb
child 495873 72189fd7d7b2986af012fa3e0ba93f7af0aad36d
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1496383
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1496383 - Fix state error cases of MediaRecorder to match the W3C spec r=jya Fix a bug that the current MediaRecorder's state error cases does not match the W3C spec. pause() and resume() should throw an INVAILD_STATE_ERR only when it is inactive state, making them independant. Simply changing if statements is enough because the underlying encoder object (TrackEncoder) will ignore Suspend/Resume calls when it is already suspended/recording so there won't be side-effects by multiple pause()/resume() calls. Differential Revision: https://phabricator.services.mozilla.com/D7910
dom/media/MediaRecorder.cpp
--- a/dom/media/MediaRecorder.cpp
+++ b/dom/media/MediaRecorder.cpp
@@ -1380,17 +1380,17 @@ MediaRecorder::Stop(ErrorResult& aResult
   MOZ_ASSERT(mSessions.Length() > 0);
   mSessions.LastElement()->Stop();
 }
 
 void
 MediaRecorder::Pause(ErrorResult& aResult)
 {
   LOG(LogLevel::Debug, ("MediaRecorder.Pause"));
-  if (mState != RecordingState::Recording) {
+  if (mState == RecordingState::Inactive) {
     aResult.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   MOZ_ASSERT(mSessions.Length() > 0);
   nsresult rv = mSessions.LastElement()->Pause();
   if (NS_FAILED(rv)) {
     NotifyError(rv);
@@ -1398,17 +1398,17 @@ MediaRecorder::Pause(ErrorResult& aResul
   }
   mState = RecordingState::Paused;
 }
 
 void
 MediaRecorder::Resume(ErrorResult& aResult)
 {
   LOG(LogLevel::Debug, ("MediaRecorder.Resume"));
-  if (mState != RecordingState::Paused) {
+  if (mState == RecordingState::Inactive) {
     aResult.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   MOZ_ASSERT(mSessions.Length() > 0);
   nsresult rv = mSessions.LastElement()->Resume();
   if (NS_FAILED(rv)) {
     NotifyError(rv);