Bug 1408702: Don't honor privacy.resistFingerprinting for media features that aren't accessible to content pages. r?xidorn draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 19 Oct 2017 15:06:38 +0200
changeset 683252 11651587ed90e0a43c62240143a546c1cfa5ec9d
parent 683181 87e3813e79396f88e63fc6cfd7f07c3dbb415195
child 736583 3ea3fc33347cf0d90956496c279c9df5e6a3fad1
push id85308
push userbmo:emilio@crisal.io
push dateThu, 19 Oct 2017 13:10:59 +0000
reviewersxidorn
bugs1408702
milestone58.0a1
Bug 1408702: Don't honor privacy.resistFingerprinting for media features that aren't accessible to content pages. r?xidorn This is kind of a band-aid because not all the media features chrome code uses happen to be banned from content pages. But I'll change that soon. Meanwhile this fixes scrollbars and such. MozReview-Commit-ID: IVHljzpxc2z
layout/style/nsMediaFeatures.cpp
--- a/layout/style/nsMediaFeatures.cpp
+++ b/layout/style/nsMediaFeatures.cpp
@@ -385,25 +385,31 @@ GetTransform3d(nsPresContext* aPresConte
   aResult.SetIntValue(1, eCSSUnit_Integer);
 }
 
 static void
 GetSystemMetric(nsPresContext* aPresContext, const nsMediaFeature* aFeature,
                 nsCSSValue& aResult)
 {
   aResult.Reset();
-  if (ShouldResistFingerprinting(aPresContext)) {
+
+  const bool isAccessibleFromContentPages =
+    !(aFeature->mReqFlags & nsMediaFeature::eUserAgentAndChromeOnly);
+
+  if (isAccessibleFromContentPages &&
+      ShouldResistFingerprinting(aPresContext)) {
     // If "privacy.resistFingerprinting" is enabled, then we simply don't
-    // return any system-backed media feature values. (No spoofed values returned.)
+    // return any system-backed media feature values. (No spoofed values
+    // returned.)
     return;
   }
 
   MOZ_ASSERT(aFeature->mValueType == nsMediaFeature::eBoolInteger,
              "unexpected type");
-  nsAtom *metricAtom = *aFeature->mData.mMetric;
+  nsAtom* metricAtom = *aFeature->mData.mMetric;
   bool hasMetric = nsCSSRuleProcessor::HasSystemMetric(metricAtom);
   aResult.SetIntValue(hasMetric ? 1 : 0, eCSSUnit_Integer);
 }
 
 static void
 GetWindowsTheme(nsPresContext* aPresContext, const nsMediaFeature* aFeature,
                 nsCSSValue& aResult)
 {