Bug 1213453 - Session-unique group id. r=pehrsons
☠☠ backed out by f63a07c8426b ☠ ☠
authorAlex Chronopoulos <achronop@gmail.com>
Fri, 08 Mar 2019 10:33:53 +0000
changeset 521014 ec1da6bbf1a71c135c6f17981468415cdffd05bb
parent 521013 f78c357f2f5f85d23f8c91a8329cd2057b81ad7f
child 521015 6208d9e15f3d71037b941e4c0294479f3097cbdb
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspehrsons
bugs1213453
milestone67.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 1213453 - Session-unique group id. r=pehrsons Spec in [1] mentions: "The browsing session-unique group identifier for the source of the MediaStreamTrack." [1] https://www.w3.org/TR/mediacapture-streams/#constrainable-properties Differential Revision: https://phabricator.services.mozilla.com/D20371
dom/media/MediaManager.cpp
dom/media/MediaManager.h
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -3010,26 +3010,34 @@ RefPtr<MediaManager::StreamPromise> Medi
   vc.mMediaSource.AssignASCII(EnumToASCII(dom::MediaSourceEnumValues::strings,
                                           MediaSourceEnum::Screen));
 
   return MediaManager::GetUserMedia(aWindow, c, aCallerType);
 }
 
 /* static */
 void MediaManager::AnonymizeDevices(MediaDeviceSet& aDevices,
-                                    const nsACString& aOriginKey) {
+                                    const nsACString& aOriginKey,
+                                    const uint64_t aWindowId) {
+
   if (!aOriginKey.IsEmpty()) {
     for (RefPtr<MediaDevice>& device : aDevices) {
       nsString id;
       device->GetId(id);
       nsString rawId(id);
       AnonymizeId(id, aOriginKey);
 
       nsString groupId;
       device->GetGroupId(groupId);
+      // Use window id to salt group id in order to make it session based as
+      // required by the spec. This does not provide unique group ids through
+      // out a browser restart. However, this is not agaist the spec.
+      // Furtermore, since device ids are the same after a browser restart the
+      // fingerprint is not bigger.
+      groupId.AppendInt(aWindowId);
       AnonymizeId(groupId, aOriginKey);
 
       device = new MediaDevice(device, id, groupId, rawId);
     }
   }
 }
 
 /* static */
@@ -3201,17 +3209,18 @@ RefPtr<MediaManager::MgrPromise> MediaMa
                    }
                  }
                }
                if (!mgr->IsWindowStillActive(aWindowId)) {
                  return MgrPromise::CreateAndReject(
                      MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError),
                      __func__);
                }
-               MediaManager::AnonymizeDevices(*aOutDevices, *originKey);
+               MediaManager::AnonymizeDevices(*aOutDevices, *originKey,
+                                              aWindowId);
                return MgrPromise::CreateAndResolve(false, __func__);
              },
              [](RefPtr<MediaMgrError>&& aError) {
                return MgrPromise::CreateAndReject(std::move(aError), __func__);
              });
 }
 
 RefPtr<MediaManager::DevicesPromise> MediaManager::EnumerateDevices(
--- a/dom/media/MediaManager.h
+++ b/dom/media/MediaManager.h
@@ -271,17 +271,18 @@ class MediaManager final : public nsIMed
   virtual void OnDeviceChange() override;
 
  private:
   static nsresult GenerateUUID(nsAString& aResult);
   static nsresult AnonymizeId(nsAString& aId, const nsACString& aOriginKey);
 
  public:  // TODO: make private once we upgrade to GCC 4.8+ on linux.
   static void AnonymizeDevices(MediaDeviceSet& aDevices,
-                               const nsACString& aOriginKey);
+                               const nsACString& aOriginKey,
+                               const uint64_t aWindowId);
   static already_AddRefed<nsIWritableVariant> ToJSArray(
       MediaDeviceSet& aDevices);
 
  private:
   enum class DeviceEnumerationType : uint8_t {
     Normal,  // Enumeration should not return loopback or fake devices
     Fake,    // Enumeration should return fake device(s)
     Loopback /* Enumeration should return loopback device(s) (possibly in