Skip to content

Commit

Permalink
Merge pull request #449 from laniakea64/master
Browse files Browse the repository at this point in the history
privacy.resistFingerprinting.block_mozAddonManager
  • Loading branch information
MrAlex94 authored Mar 5, 2018
2 parents 32fab29 + 835188b commit 79492ec
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ support-files =
file_workerPerformance.js
head.js

[browser_block_mozAddonManager.js]
[browser_navigator.js]
[browser_netInfo.js]
[browser_performanceAPI.js]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Bug 1384330 - A test case for making sure the navigator.mozAddonManager will
* be blocked when pref 'privacy.resistFingerprinting.block_mozAddonManager' is true.
*/

const TEST_PATH = "https://example.com/browser/browser/" +
"components/resistfingerprinting/test/browser/"

add_task(async function test() {
await SpecialPowers.pushPrefEnv({"set":
[["extensions.webapi.testing", true]]
});

for (let pref of [false, true]) {
await SpecialPowers.pushPrefEnv({"set":
[["privacy.resistFingerprinting.block_mozAddonManager", pref]]
});

let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser, TEST_PATH + "file_dummy.html");

await ContentTask.spawn(tab.linkedBrowser, pref, function(aPref) {
if (aPref) {
is(content.navigator.mozAddonManager, undefined,
"The navigator.mozAddonManager should not exist when the pref is on.");
} else {
ok(content.navigator.mozAddonManager,
"The navigator.mozAddonManager should exist when the pref is off.");
}
});

await BrowserTestUtils.removeTab(tab);
await SpecialPowers.popPrefEnv();
}
});
6 changes: 6 additions & 0 deletions toolkit/mozapps/extensions/AddonManagerWebAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ using namespace mozilla::dom;

static bool
IsValidHost(const nsACString& host) {
// This hidden pref allows users to disable mozAddonManager entirely if they want
// for fingerprinting resistance. Someone like Tor browser will use this pref.
if (Preferences::GetBool("privacy.resistFingerprinting.block_mozAddonManager")) {
return false;
}

// This is ugly, but Preferences.h doesn't have support
// for default prefs or locked prefs
nsCOMPtr<nsIPrefService> prefService (do_GetService(NS_PREFSERVICE_CONTRACTID));
Expand Down

0 comments on commit 79492ec

Please sign in to comment.