commit a46cfb4e6bad6756c9e9f0f1f88ac1f7d11caa11
parent 1959300e0cb4fccc0ff13df3a5f4abeba4db98db
Author: Rob Wu <rob@robwu.nl>
Date: Tue, 30 Dec 2025 16:08:19 +0000
Bug 2001887 - Stop creating ~/.mozilla/extensions directory r=mkaply
Differential Revision: https://phabricator.services.mozilla.com/D277627
Diffstat:
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/security/sandbox/test/browser_content_sandbox_fs_tests.js b/security/sandbox/test/browser_content_sandbox_fs_tests.js
@@ -682,6 +682,13 @@ async function testFileAccessWindowsOnly() {
let tests = [];
let extDir = GetPerUserExtensionDir();
+ // We used to unconditionally create this directory from Firefox, but that
+ // was dropped in bug 2001887. The value of this directory is questionable;
+ // the test was added in Firefox 56 (bug 1403744) to cover legacy add-ons,
+ // but legacy add-on support was discontinued in Firefox 57, and we stopped
+ // sideloading add-ons from this directory on all builds except ESR in
+ // Firefox 74 (bug 1602840).
+ await IOUtils.makeDirectory(extDir.path);
tests.push({
desc: "per-user extensions dir",
ok: true,
diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp
@@ -1184,8 +1184,13 @@ nsresult nsXREDirProvider::GetSysUserExtensionsDirectory(nsIFile** aFile) {
rv = AppendSysUserExtensionPath(localDir);
NS_ENSURE_SUCCESS(rv, rv);
- rv = EnsureDirectoryExists(localDir);
- NS_ENSURE_SUCCESS(rv, rv);
+ // We used to unconditionally create the directory here, but that results in
+ // an unwanted ~/.mozilla/extensions/ in violation of the XDG basedir spec,
+ // which expresses a preference for ~/.config/mozilla/.
+ //
+ // Since we no longer support sideloading from this directory, unless
+ // MOZ_ALLOW_ADDON_SIDELOAD is set, the creation of the directory is almost
+ // always redundant, so skip the creation of the directory.
localDir.forget(aFile);
return NS_OK;