Bug 1479240: Make system metric queries always return false instead of not matching for fingerprinting-resistance. r=heycam

Looks like these used this mechanism for no great reason, and actually doing
this exposes trivially whether fingerprinting-resistance is enabled, which looks
like an anti-goal (if a media query parses correctly, and doesn't match either 1
or 0, then fingerprinting-resistance is enabled).

Differential Revision: https://phabricator.services.mozilla.com/D2493

MozReview-Commit-ID: 76tIIkwlpeP
This commit is contained in:
Emilio Cobos Álvarez 2018-07-29 04:03:03 +02:00
Родитель 27932e0385
Коммит 27250792bc
2 изменённых файлов: 15 добавлений и 15 удалений

Просмотреть файл

@ -393,8 +393,15 @@ GetTransform3d(nsIDocument* aDocument, const nsMediaFeature*,
}
static bool
HasSystemMetric(nsAtom* aMetric)
HasSystemMetric(nsIDocument* aDocument,
nsAtom* aMetric,
bool aIsAccessibleFromContent)
{
if (aIsAccessibleFromContent &&
nsContentUtils::ShouldResistFingerprinting(aDocument)) {
return false;
}
nsMediaFeatures::InitSystemMetrics();
return sSystemMetrics->IndexOf(aMetric) != sSystemMetrics->NoIndex;
}
@ -403,27 +410,17 @@ static void
GetSystemMetric(nsIDocument* aDocument, const nsMediaFeature* aFeature,
nsCSSValue& aResult)
{
aResult.Reset();
const bool isAccessibleFromContentPages =
!(aFeature->mReqFlags & nsMediaFeature::eUserAgentAndChromeOnly);
MOZ_ASSERT(!isAccessibleFromContentPages ||
*aFeature->mName == nsGkAtoms::_moz_touch_enabled);
if (isAccessibleFromContentPages &&
nsContentUtils::ShouldResistFingerprinting(aDocument)) {
// If "privacy.resistFingerprinting" is enabled, then we simply don't
// 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;
bool hasMetric = HasSystemMetric(metricAtom);
bool hasMetric =
HasSystemMetric(aDocument, metricAtom, isAccessibleFromContentPages);
aResult.SetIntValue(hasMetric ? 1 : 0, eCSSUnit_Integer);
}

Просмотреть файл

@ -104,10 +104,13 @@ var testToggles = function (resisting) {
suppressed_toggles.forEach(
function (key) {
var exists = keyValMatches(key, 0) || keyValMatches(key, 1);
if (resisting || (!toggles_enabled_in_content.includes(key) && !is_chrome_window)) {
if (!toggles_enabled_in_content.includes(key) && !is_chrome_window) {
ok(!exists, key + " should not exist.");
} else {
ok(exists, key + " should exist.");
if (resisting) {
ok(keyValMatches(key, 0) && !keyValMatches(key, 1), "Should always match as false");
}
}
});
};
@ -214,7 +217,7 @@ var generateCSSLines = function (resisting) {
if (!toggles_enabled_in_content.includes(key) && !resisting && !is_chrome_window) {
lines += "#" + key + " { background-color: green; }\n";
} else {
lines += suppressedMediaQueryCSSLine(key, resisting ? "red" : "green");
lines += suppressedMediaQueryCSSLine(key, "green");
}
});
if (OS === "WINNT") {