Bug 1372073 - Suppress devicechange event. r=arthuredelstein,mchiang
authorChung-Sheng Fu <cfu@mozilla.com>
Tue, 19 Sep 2017 09:56:48 +0800
changeset 391513 2133a8484ef07a58bcdcd8cae0b60f9eb819b035
parent 391512 f995ab0441e92a820d19015d8c31a927749761c8
child 391514 e04a7ec9c152777566405216ecfa79840b317c56
push id32892
push userncsoregi@mozilla.com
push dateMon, 13 Nov 2017 22:56:04 +0000
treeherdermozilla-central@3dddb19f2a07 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarthuredelstein, mchiang
bugs1372073
milestone59.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 1372073 - Suppress devicechange event. r=arthuredelstein,mchiang MozReview-Commit-ID: JxxFbOMBQvY
dom/media/MediaDevices.cpp
--- a/dom/media/MediaDevices.cpp
+++ b/dom/media/MediaDevices.cpp
@@ -4,16 +4,17 @@
 
 #include "mozilla/dom/MediaDevices.h"
 #include "mozilla/dom/MediaStreamBinding.h"
 #include "mozilla/dom/MediaDeviceInfo.h"
 #include "mozilla/dom/MediaDevicesBinding.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/MediaManager.h"
 #include "MediaTrackConstraints.h"
+#include "nsContentUtils.h"
 #include "nsIEventTarget.h"
 #include "nsINamed.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIPermissionManager.h"
 #include "nsPIDOMWindow.h"
 #include "nsQueryObject.h"
 
 #define DEVICECHANGE_HOLD_TIME_IN_MS 1000
@@ -227,16 +228,22 @@ MediaDevices::OnDeviceChange()
     return;
   }
 
   if (!(MediaManager::Get()->IsActivelyCapturingOrHasAPermission(GetOwner()->WindowID()) ||
     Preferences::GetBool("media.navigator.permission.disabled", false))) {
     return;
   }
 
+  // Do not fire event to content script when
+  // privacy.resistFingerprinting is true.
+  if (nsContentUtils::ShouldResistFingerprinting()) {
+    return;
+  }
+
   if (!mFuzzTimer)
   {
     mFuzzTimer = NS_NewTimer();
   }
 
   if (!mFuzzTimer) {
     MOZ_ASSERT(false);
     return;