Bug 927358 - Was mistake to begin failing on unsupported mandatory constraints. r=jesup, a=bajaj
authorJan-Ivar Bruaroey <jib@mozilla.com>
Fri, 22 Nov 2013 16:10:00 -0500
changeset 167541 8f1a8bfca0df9282226f7ee9ef63cec302924fa1
parent 167540 f403af8356f9114fb6fcee7e61b8e377f7f3b42e
child 167542 5b2e09991c01cdb8cbc4f480a1ad1e5a171a01a6
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, bajaj
bugs927358
milestone27.0a2
Bug 927358 - Was mistake to begin failing on unsupported mandatory constraints. r=jesup, a=bajaj
dom/media/MediaManager.cpp
dom/media/tests/mochitest/test_getUserMedia_constraints.html
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -1271,27 +1271,29 @@ MediaManager::GetUserMedia(JSContext* aC
   StreamListeners* listeners = GetActiveWindows()->Get(windowID);
   if (!listeners) {
     listeners = new StreamListeners;
     GetActiveWindows()->Put(windowID, listeners);
   }
 
   if (!unknownConstraintFound.IsEmpty()) {
     // An unsupported mandatory constraint was found.
-    // Things are set up enough here that we can fire Error callback.
+    //
+    // We continue to ignore these for now, because we implement just
+    // facingMode, which means all existing uses of mandatory width/height would
+    // fail on Firefox only otherwise, which is undesirable.
+    //
+    // There's also basis for always ignoring them in a new proposal.
+    // TODO(jib): This is a super-low-risk fix for backport. Clean up later.
 
     LOG(("Unsupported mandatory constraint: %s\n",
           NS_ConvertUTF16toUTF8(unknownConstraintFound).get()));
 
-    nsString errormsg(NS_LITERAL_STRING("NOT_SUPPORTED_ERR: "));
-    errormsg.Append(unknownConstraintFound);
-    NS_DispatchToMainThread(new ErrorCallbackRunnable(onSuccess.forget(),
-                                                      onError.forget(),
-                                                      errormsg, windowID));
-    return NS_OK;
+    // unknown constraints existed in aRawConstraints only, which is unused
+    // from here, so continuing here effectively ignores them, as is desired.
   }
 
   // Ensure there's a thread for gum to proxy to off main thread
   nsIThread *mediaThread = MediaManager::GetThread();
 
   // Create a disabled listener to act as a placeholder
   GetUserMediaCallbackMediaStreamListener* listener =
     new GetUserMediaCallbackMediaStreamListener(mediaThread, windowID);
--- a/dom/media/tests/mochitest/test_getUserMedia_constraints.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_constraints.html
@@ -20,32 +20,25 @@ https://bugzilla.mozilla.org/show_bug.cg
 <script type="application/javascript">
 /**
   Tests covering gUM constraints API for audio, video and fake video. Exercise
   successful parsing code and ensure that unknown mandatory constraints and
   overconstraining cases produce appropriate errors.
 */
 var tests = [
   // Each test here tests a different constraint or codepath.
-  { message: "unknown mandatory constraint on video fails",
-    constraints: { video: { mandatory: { somethingUnknown:0 } } },
-    error: "NOT_SUPPORTED_ERR: somethingUnknown",
-    pass: false },
-  { message: "unknown mandatory constraint on audio fails",
-    constraints: { audio: { mandatory: { somethingUnknown:0 } } },
-    error: "NOT_SUPPORTED_ERR: somethingUnknown",
-    pass: false },
   { message: "video overconstrained by facingMode fails",
     constraints: { video: { mandatory: { facingMode:'left' } } },
     error: "NO_DEVICES_FOUND",
     pass: false },
   { message: "Success-path: optional video facingMode + audio ignoring facingMode",
     constraints: { fake: true,
                    audio: { mandatory: { facingMode:'left' } },
-                   video: { optional: [{ facingMode:'left' },
+                   video: { mandatory: { somethingUnknown:0 },
+                            optional: [{ facingMode:'left' },
                                        { facingMode:'right' },
                                        { facingMode:'environment' },
                                        { facingMode:'user' },
                                        { foo:0 }] } },
     error: null,
     pass: false },
   { message: null },
 ];