Bug 1756280: Test combinations of privacy.resistFingerprinting and pdfjs.disabled in navigator r=peterv

RFP should make navigator ignore pdfjs.disabled and always report that a PDF viewer is supported.  It should also return the hard-coded values for navigator.plugins and navigator.mimeTypes.  Without RFP, navigator.pdfViewerSupported should be false and plugins and mimeTypes should be empty when pdfjs.disabled is set.

Differential Revision: https://phabricator.services.mozilla.com/D140763
This commit is contained in:
David Parks 2022-03-17 20:15:21 +00:00
Родитель 31e0947dd1
Коммит 7cde443dc0
2 изменённых файлов: 28 добавлений и 37 удалений

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

@ -378,10 +378,10 @@ add_task(async function setupResistFingerprinting() {
testDesc: "spoofed",
appVersion: SPOOFED_APPVERSION[AppConstants.platform],
hardwareConcurrency: SPOOFED_HW_CONCURRENCY,
mimeTypesLength: 0,
mimeTypesLength: 2,
oscpu: SPOOFED_OSCPU[AppConstants.platform],
platform: SPOOFED_PLATFORM[AppConstants.platform],
pluginsLength: 0,
pluginsLength: 5,
userAgentNavigator: spoofedUserAgentNavigator,
userAgentHeader: spoofedUserAgentHeader,
};

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

@ -15,48 +15,39 @@ https://bugzilla.mozilla.org/1281963
<script class="testbody" type="application/javascript">
// __setPref(key, value)__.
// Set a pref value asynchronously, returning a promise that resolves
// when it succeeds.
let setPref = function(key, value) {
let pushPref = function(key, value) {
return SpecialPowers.pushPrefEnv({"set": [[key, value]]});
};
// Run a test to see that we don't expose the supported mimeTypes
// or installed plugins when "privacy.resistFingerprinting" is active.
let popPref = function() {
SpecialPowers.popPrefEnv();
};
// Run a test to see that we don't hide the hard-coded mimeTypes
// or plugins when "privacy.resistFingerprinting" is active.
// See bug 1756280.
add_task(async function() {
let exampleMimeType = undefined,
examplePlugin = undefined;
// Disable fingerprinting resistance.
await setPref("privacy.resistFingerprinting", false);
// Depending on the testing platform, we may have at least
// one mimeType and plugin available.
exampleMimeType = navigator.mimeTypes[0];
examplePlugin = navigator.plugins[0];
for (let rfpEnabled of [true, false]) {
await pushPref("privacy.resistFingerprinting", rfpEnabled);
for (let pdfDisabled of [true, false]) {
await pushPref("pdfjs.disabled", pdfDisabled);
if (pdfDisabled && !rfpEnabled) {
is(navigator.mimeTypes.length, 0, "navigator.mimeTypes.length should be 0");
is(navigator.plugins.length, 0, "navigator.plugins.length should 0");
} else {
let exampleMimeType = navigator.mimeTypes[0];
let examplePlugin = navigator.plugins[0];
// First check that we can retrieve mimeType or plugin by name and that
// the array length is nonzero.
if (exampleMimeType) {
isnot(navigator.mimeTypes[exampleMimeType.type], undefined, "Should reveal mime type");
isnot(navigator.mimeTypes.length, 0, "navigator.mimeTypes.length should be nonzero");
}
if (examplePlugin) {
isnot(navigator.plugins[examplePlugin.name], undefined, "Should reveal plugin");
isnot(navigator.plugins.length, 0, "navigator.plugins.length should be nonzero");
}
isnot(navigator.mimeTypes[exampleMimeType.type], undefined, "Should reveal mime type");
is(navigator.mimeTypes.length, 2, "navigator.mimeTypes.length should be 2");
// Now test with fingerprinting resistance enabled
await setPref("privacy.resistFingerprinting", true);
if (exampleMimeType) {
is(navigator.mimeTypes[exampleMimeType.type], undefined, "Don't reveal mime type");
isnot(navigator.plugins[examplePlugin.name], undefined, "Should reveal plugin");
is(navigator.plugins.length, 5, "navigator.plugins.length should be nonzero");
}
await popPref();
}
await popPref();
}
is(navigator.mimeTypes[0], undefined, "Don't reveal mime type");
is(navigator.mimeTypes.length, 0, "navigator.mimeTypes.length should be 0");
if (examplePlugin) {
is(navigator.plugins[examplePlugin.name], undefined, "Don't reveal plugin");
}
is(navigator.plugins[0], undefined, "Don't reveal plugin");
is(navigator.plugins.length, 0, "navigator.plugins.length should be 0");
});
</script>