Bug 1452031 - Close fingerprint concern by removing code no longer needed to handle NotFoundError spec case. r=pehrsons
authorJan-Ivar Bruaroey <jib@mozilla.com>
Tue, 10 Apr 2018 01:49:15 -0400
changeset 412975 abc6e8447dc08c7526a455b5f9b5d2e615fa6fe9
parent 412974 043493cdf0d5e2b3a55ddb2a5249967796ecd1eb
child 412976 2198e282bdcf9cee653dfa3e4fd365444b4ef60a
push id33828
push userarchaeopteryx@coole-files.de
push dateThu, 12 Apr 2018 19:19:41 +0000
treeherdermozilla-central@6e22c4a726c2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspehrsons
bugs1452031
milestone61.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 1452031 - Close fingerprint concern by removing code no longer needed to handle NotFoundError spec case. r=pehrsons MozReview-Commit-ID: KVQjO18PL0I
browser/modules/ContentWebRTC.jsm
dom/media/MediaManager.cpp
--- a/browser/modules/ContentWebRTC.jsm
+++ b/browser/modules/ContentWebRTC.jsm
@@ -143,19 +143,19 @@ function handleGUMRequest(aSubject, aTop
       // devices, there's nothing to do in the callback anymore.
       if (contentWindow.closed)
         return;
 
       prompt(contentWindow, aSubject.windowID, aSubject.callID,
              constraints, devices, secure, isHandlingUserInput);
     },
     function(error) {
-      // bug 827146 -- In the future, the UI should catch NotFoundError
-      // and allow the user to plug in a device, instead of immediately failing.
-      denyGUMRequest({callID: aSubject.callID}, error);
+      // Device enumeration is done ahead of handleGUMRequest, so we're not
+      // responsible for handling the NotFoundError spec case.
+      denyGUMRequest({callID: aSubject.callID});
     },
     aSubject.innerWindowID,
     aSubject.callID);
 }
 
 function prompt(aContentWindow, aWindowID, aCallID, aConstraints, aDevices, aSecure, aIsHandlingUserInput) {
   let audioDevices = [];
   let videoDevices = [];
@@ -198,17 +198,19 @@ function prompt(aContentWindow, aWindowI
 
   let requestTypes = [];
   if (videoDevices.length)
     requestTypes.push(sharingScreen ? "Screen" : "Camera");
   if (audioDevices.length)
     requestTypes.push(sharingAudio ? "AudioCapture" : "Microphone");
 
   if (!requestTypes.length) {
-    denyGUMRequest({callID: aCallID}, "NotFoundError");
+    // Device enumeration is done ahead of handleGUMRequest, so we're not
+    // responsible for handling the NotFoundError spec case.
+    denyGUMRequest({callID: aCallID});
     return;
   }
 
   if (!aContentWindow.pendingGetUserMediaRequests) {
     setupPendingListsInitially(aContentWindow);
   }
   aContentWindow.pendingGetUserMediaRequests.set(aCallID, devices);
 
@@ -230,23 +232,18 @@ function prompt(aContentWindow, aWindowI
     audioDevices,
     videoDevices
   };
 
   let mm = getMessageManagerForWindow(aContentWindow);
   mm.sendAsyncMessage("webrtc:Request", request);
 }
 
-function denyGUMRequest(aData, aError) {
-  let msg = null;
-  if (aError) {
-    msg = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
-    msg.data = aError;
-  }
-  Services.obs.notifyObservers(msg, "getUserMedia:response:deny", aData.callID);
+function denyGUMRequest(aData) {
+  Services.obs.notifyObservers(null, "getUserMedia:response:deny", aData.callID);
 
   if (!aData.windowID)
     return;
   let contentWindow = Services.wm.getOuterWindowWithId(aData.windowID);
   if (contentWindow.pendingGetUserMediaRequests)
     forgetGUMRequest(contentWindow, aData.callID);
 }
 
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -3660,37 +3660,21 @@ MediaManager::Observe(nsISupports* aSubj
       return task->Denied(MediaMgrError::Name::AbortError,
                           NS_LITERAL_STRING("In shutdown"));
     }
     // Reuse the same thread to save memory.
     MediaManager::PostTask(task.forget());
     return NS_OK;
 
   } else if (!strcmp(aTopic, "getUserMedia:response:deny")) {
-    MediaMgrError::Name errorName = MediaMgrError::Name::NotAllowedError;
-
-    if (aSubject) {
-      nsCOMPtr<nsISupportsString> msg(do_QueryInterface(aSubject));
-      MOZ_ASSERT(msg);
-      nsString msgData;
-      msg->GetData(msgData);
-      // The only errors other than NotAllowedError allowed by the getUserMedia
-      // spec related to selection are NotFoundError for no valid options and
-      // the catch-all AbortError for everything else (NotReadableError is
-      // reserved for device startup errors later).
-      errorName = (msgData.EqualsLiteral("NotFoundError"))
-          ? MediaMgrError::Name::NotFoundError
-          : MediaMgrError::Name::AbortError;
-    }
-
     nsString key(aData);
     RefPtr<GetUserMediaTask> task;
     mActiveCallbacks.Remove(key, getter_AddRefs(task));
     if (task) {
-      task->Denied(errorName);
+      task->Denied(MediaMgrError::Name::NotAllowedError);
       nsTArray<nsString>* array;
       if (!mCallIds.Get(task->GetWindowID(), &array)) {
         return NS_OK;
       }
       array->RemoveElement(key);
       SendPendingGUMRequest();
     }
     return NS_OK;