Bug 1461454 - In RFP Mode, Spoof Smooth=True and PowerEfficient=False for Supported Media in MediaCapabilities r=jya

Uplifts Tor Browser patch for Tor Bug 13543 and adds a test.

Differential Revision: https://phabricator.services.mozilla.com/D89044
This commit is contained in:
sanketh 2020-09-07 03:23:36 +00:00
Родитель 938d1e79b0
Коммит b68c36a5da
3 изменённых файлов: 75 добавлений и 0 удалений

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

@ -288,6 +288,11 @@ already_AddRefed<Promise> MediaCapabilities::DecodingInfo(
if (aValue.IsReject()) {
p = CapabilitiesPromise::CreateAndReject(
std::move(aValue.RejectValue()), __func__);
} else if (nsContentUtils::ShouldResistFingerprinting()) {
p = CapabilitiesPromise::CreateAndResolve(
MediaCapabilitiesInfo(true /* supported */,
true /* smooth */, false /* power efficient */),
__func__);
} else {
MOZ_ASSERT(config->IsVideo());
if (StaticPrefs::media_mediacapabilities_from_database()) {

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

@ -883,6 +883,7 @@ scheme=https
[test_looping_eventsOrder.html]
[test_media_selection.html]
[test_media_sniffer.html]
[test_mediacapabilities_resistfingerprinting.html]
[test_mediarecorder_avoid_recursion.html]
skip-if = os == 'win' && !debug
scheme=https

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

@ -0,0 +1,69 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for Bug 1369309</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="manifest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1461454">Mozilla Bug 1461454</a>
<a target="_blank" href="https://gitlab.torproject.org/tpo/applications/tor-browser/-/issues/13543">Tor Issue 13543</a>
<script type="application/javascript">
async function testWhetherSpoofed(resistFingerprinting) {
var unsupportedVideoConfiguration = {
contentType: 'video/bogus',
width: 800,
height: 600,
bitrate: 3000,
framerate: 24,
};
var supportedVideoConfiguration = {
contentType: 'video/webm; codecs="vp09.00.10.08"',
width: 800,
height: 600,
bitrate: 3000,
framerate: 24,
};
await SpecialPowers.pushPrefEnv({
"set": [
["privacy.resistFingerprinting", resistFingerprinting]
],
});
var result;
result = await navigator.mediaCapabilities.decodingInfo({
type: 'file',
video: unsupportedVideoConfiguration
});
is(result.supported, false, "video/bogus should be unsupported.");
is(result.smooth, false, "smooth is false when unsupported.");
is(result.powerEfficient, false, "powerEfficient is false when unsupported.");
result = await navigator.mediaCapabilities.decodingInfo({
type: 'file',
video: supportedVideoConfiguration
});
is(result.supported, true, "'video/webm; codecs=\"vp09.00.10.08\"' should be supported.");
if (resistFingerprinting) {
is(result.smooth, true, "smooth should be spoofed to true in RFP mode.");
is(result.powerEfficient, false, "powerEfficient should be spoofed to false in RFP mode.");
}
}
async function start() {
await testWhetherSpoofed(true);
await testWhetherSpoofed(false);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
start();
</script>
</body>
</html>