Bug 1229240 - make applyConstraints() reject instead of crash on non-gUM tracks. r=jesup, a=sylvestre
authorJan-Ivar Bruaroey <jib@mozilla.com>
Tue, 01 Dec 2015 15:27:26 -0500
changeset 305978 541df44447ab8801f16e55678b93efc780cf6d3d
parent 305977 2f410ff434e82ab8ee377e879560420b27e35c71
child 305979 2b96b7c71910c24c32ef825e3deb280ebed13ef1
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, sylvestre
bugs1229240
milestone44.0
Bug 1229240 - make applyConstraints() reject instead of crash on non-gUM tracks. r=jesup, a=sylvestre
dom/media/DOMMediaStream.cpp
--- a/dom/media/DOMMediaStream.cpp
+++ b/dom/media/DOMMediaStream.cpp
@@ -13,16 +13,17 @@
 #include "mozilla/dom/LocalMediaStreamBinding.h"
 #include "mozilla/dom/AudioNode.h"
 #include "AudioChannelAgent.h"
 #include "mozilla/dom/AudioTrack.h"
 #include "mozilla/dom/AudioTrackList.h"
 #include "mozilla/dom/VideoTrack.h"
 #include "mozilla/dom/VideoTrackList.h"
 #include "mozilla/dom/HTMLCanvasElement.h"
+#include "mozilla/dom/MediaStreamError.h"
 #include "MediaStreamGraph.h"
 #include "AudioStreamTrack.h"
 #include "VideoStreamTrack.h"
 #include "Layers.h"
 
 #ifdef LOG
 #undef LOG
 #endif
@@ -712,17 +713,26 @@ DOMMediaStream::StopTrack(TrackID aTrack
   }
 }
 
 already_AddRefed<Promise>
 DOMMediaStream::ApplyConstraintsToTrack(TrackID aTrackID,
                                         const MediaTrackConstraints& aConstraints,
                                         ErrorResult &aRv)
 {
-  return nullptr;
+  nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(mWindow);
+  RefPtr<Promise> promise = Promise::Create(go, aRv);
+  MOZ_RELEASE_ASSERT(!aRv.Failed());
+
+  promise->MaybeReject(new MediaStreamError(
+      static_cast<nsPIDOMWindow*>(mWindow.get()),
+      NS_LITERAL_STRING("OverconstrainedError"),
+      NS_LITERAL_STRING(""),
+      NS_LITERAL_STRING("")));
+  return promise.forget();
 }
 
 bool
 DOMMediaStream::CombineWithPrincipal(nsIPrincipal* aPrincipal)
 {
   bool changed =
     nsContentUtils::CombineResourcePrincipals(&mPrincipal, aPrincipal);
   if (changed) {