about summary refs log tree commit diff
path: root/config/firefox/release/D6695.diff
diff options
context:
space:
mode:
Diffstat (limited to 'config/firefox/release/D6695.diff')
-rw-r--r--config/firefox/release/D6695.diff405
1 files changed, 405 insertions, 0 deletions
diff --git a/config/firefox/release/D6695.diff b/config/firefox/release/D6695.diff
new file mode 100644
index 000000000000..d15342ba50fa
--- /dev/null
+++ b/config/firefox/release/D6695.diff
@@ -0,0 +1,405 @@
+diff --git a/toolkit/moz.build b/toolkit/moz.build
+index 109fb2ce9..0b871d931 100644
+--- a/toolkit/moz.build
++++ b/toolkit/moz.build
+@@ -72,3 +72,5 @@ with Files('mozapps/preferences/**'):
+ with Files('pluginproblem/**'):
+     BUG_COMPONENT = ('Core', 'Plug-ins')
+ 
++if CONFIG['ENABLE_TESTS']:
++    DIRS += ['tests/gtest']
+diff --git a/toolkit/tests/gtest/TestXREAppDir.cpp b/toolkit/tests/gtest/TestXREAppDir.cpp
+new file mode 100644
+index 000000000..afa5f1b54
+--- /dev/null
++++ b/toolkit/tests/gtest/TestXREAppDir.cpp
+@@ -0,0 +1,94 @@
++/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
++/* vim:set ts=2 sw=2 sts=2 et cindent: */
++/* This Source Code Form is subject to the terms of the Mozilla Public
++ * License, v. 2.0. If a copy of the MPL was not distributed with this
++ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
++
++#include "nsXREDirProvider.h"
++#include "gtest/gtest.h"
++
++#if defined(XP_UNIX) && !defined(XP_MACOSX)
++
++#include <stdlib.h>
++#include <unistd.h>
++#include <sys/stat.h>
++
++// Remove @path and all its subdirs.
++static void
++cleanup(std::string path)
++{
++  nsresult rv;
++  nsCOMPtr<nsIFile> localDir;
++  rv = NS_NewNativeLocalFile(
++    nsDependentCString((char*)path.c_str()), true, getter_AddRefs(localDir));
++  EXPECT_EQ(NS_OK, rv);
++  rv = localDir->Remove(true);
++  EXPECT_EQ(NS_OK, rv);
++}
++
++// Create a temp dir and set HOME to it.
++// Upon successful completion, return the string with the path of the homedir.
++static std::string
++getNewHome()
++{
++  char tmpHomedir[] = "/tmp/mozilla-tmp.XXXXXX";
++  std::string homedir = mkdtemp(tmpHomedir);
++  EXPECT_EQ(0, setenv("HOME", (char*)homedir.c_str(), 1));
++  return homedir;
++}
++
++// Check if '$HOME/.mozilla' is used when it exists.
++TEST(toolkit_xre, LegacyAppUserDir)
++{
++  nsCOMPtr<nsIFile> localDir;
++  nsresult rv;
++  nsAutoCString cwd;
++  std::string homedir = getNewHome();
++  ASSERT_EQ(0, mkdir((char*)(homedir + "/.mozilla").c_str(), S_IRWXU));
++  rv = nsXREDirProvider::GetUserAppDataDirectory(getter_AddRefs(localDir));
++  ASSERT_EQ(NS_OK, rv);
++  localDir->GetNativePath(cwd);
++  std::string expectedAppDir = homedir + "/.mozilla/firefox";
++  std::string appDir = cwd.get();
++  ASSERT_EQ(expectedAppDir, appDir);
++  cleanup(homedir);
++}
++
++// Check if '$HOME/.local/share/mozilla' is used
++// if $HOME/.mozilla does not exist and the env
++// variable XDG_DATA_HOME is not set.
++TEST(toolkit_xre, XDGDefaultAppUserDir)
++{
++  nsCOMPtr<nsIFile> localDir;
++  nsresult rv;
++  nsAutoCString cwd;
++  std::string homedir = getNewHome();
++  ASSERT_EQ(0, unsetenv("XDG_DATA_HOME"));
++  rv = nsXREDirProvider::GetUserAppDataDirectory(getter_AddRefs(localDir));
++  ASSERT_EQ(NS_OK, rv);
++  localDir->GetNativePath(cwd);
++  std::string expectedAppDir = homedir + "/.local/share/mozilla/firefox";
++  std::string appDir = cwd.get();
++  ASSERT_EQ(expectedAppDir, appDir);
++  cleanup(homedir);
++}
++
++// Check if '$XDG_DATA_HOME/mozilla' is
++// used if '$HOME/.mozilla' does not exist
++// and the env variable XDG_DATA_HOME is set.
++TEST(toolkit_xre, XDGAppUserDir)
++{
++  nsCOMPtr<nsIFile> localDir;
++  nsresult rv;
++  nsAutoCString cwd;
++  std::string homedir = getNewHome();
++  ASSERT_EQ(0, setenv("XDG_DATA_HOME", (char*)homedir.c_str(), 1));
++  rv = nsXREDirProvider::GetUserAppDataDirectory(getter_AddRefs(localDir));
++  ASSERT_EQ(NS_OK, rv);
++  localDir->GetNativePath(cwd);
++  std::string expectedAppDir = homedir + "/mozilla/firefox";
++  std::string appDir = cwd.get();
++  ASSERT_EQ(expectedAppDir, appDir);
++  cleanup(homedir);
++}
++#endif
+diff --git a/toolkit/tests/gtest/moz.build b/toolkit/tests/gtest/moz.build
+new file mode 100644
+index 000000000..4c1a10181
+--- /dev/null
++++ b/toolkit/tests/gtest/moz.build
+@@ -0,0 +1,17 @@
++# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
++# vim: set filetype=python:
++# This Source Code Form is subject to the terms of the Mozilla Public
++# License, v. 2.0. If a copy of the MPL was not distributed with this
++# file, you can obtain one at http://mozilla.org/MPL/2.0/.
++
++Library('toolkit')
++
++UNIFIED_SOURCES = [
++    'TestXREAppDir.cpp',
++]
++
++LOCAL_INCLUDES += [
++  '/toolkit/xre'
++]
++
++FINAL_LIBRARY = 'xul-gtest'
+diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp
+index 62da8de9b..164d7792e 100644
+--- a/toolkit/xre/nsXREDirProvider.cpp
++++ b/toolkit/xre/nsXREDirProvider.cpp
+@@ -421,13 +421,6 @@ nsXREDirProvider::GetFile(const char* aProperty, bool* aPersistent,
+     nsCOMPtr<nsIFile> localDir;
+     rv = GetUserDataDirectoryHome(getter_AddRefs(localDir), false);
+     if (NS_SUCCEEDED(rv)) {
+-#if defined(XP_MACOSX)
+-      rv = localDir->AppendNative(NS_LITERAL_CSTRING("Mozilla"));
+-#else
+-      rv = localDir->AppendNative(NS_LITERAL_CSTRING(".mozilla"));
+-#endif
+-    }
+-    if (NS_SUCCEEDED(rv)) {
+       localDir.swap(file);
+     }
+   }
+@@ -1381,7 +1374,8 @@ nsXREDirProvider::GetUpdateRootDir(nsIFile* *aResult)
+                                          GetAppName())))) {
+       return NS_ERROR_FAILURE;
+     }
+-  } else if (NS_FAILED(localDir->AppendNative(NS_LITERAL_CSTRING("Mozilla")))) {
++  }
++  else if (NS_FAILED(localDir->AppendNative(NS_LITERAL_CSTRING("Mozilla")))) {
+     return NS_ERROR_FAILURE;
+   }
+ 
+@@ -1562,6 +1556,9 @@ nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile, bool aLocal)
+   NS_ENSURE_SUCCESS(rv, rv);
+ 
+   localDir = dirFileMac;
++
++  rv = localDir->AppendRelativeNativePath(nsDependentCString("Mozilla"));
++  NS_ENSURE_SUCCESS(rv, rv);
+ #elif defined(XP_IOS)
+   nsAutoCString userDir;
+   if (GetUIKitDirectory(aLocal, userDir)) {
+@@ -1587,6 +1584,9 @@ nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile, bool aLocal)
+   NS_ENSURE_SUCCESS(rv, rv);
+ 
+   rv = NS_NewLocalFile(path, true, getter_AddRefs(localDir));
++  NS_ENSURE_SUCCESS(rv, rv);
++  rv = localDir->AppendRelativeNativePath(nsDependentCString("Mozilla"));
++  NS_ENSURE_SUCCESS(rv, rv);
+ #elif defined(XP_UNIX)
+   const char* homeDir = getenv("HOME");
+   if (!homeDir || !*homeDir)
+@@ -1609,8 +1609,51 @@ nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile, bool aLocal)
+         rv = localDir->AppendNative(NS_LITERAL_CSTRING(".cache"));
+     }
+   } else {
++    bool exists;
++    // check old config ~/.mozilla
+     rv = NS_NewNativeLocalFile(nsDependentCString(homeDir), true,
+                                getter_AddRefs(localDir));
++    NS_ENSURE_SUCCESS(rv, rv);
++    rv = localDir->AppendRelativeNativePath(nsDependentCString(".mozilla"));
++    NS_ENSURE_SUCCESS(rv, rv);
++    rv = localDir->Exists(&exists);
++    NS_ENSURE_SUCCESS(rv, rv);
++    // otherwise, use new config
++    if (!exists) {
++      const char* xdghomedir = getenv("XDG_DATA_HOME");
++      if (!xdghomedir || !*xdghomedir) {
++        rv = NS_NewNativeLocalFile(nsDependentCString(homeDir), true,
++                                   getter_AddRefs(localDir));
++        NS_ENSURE_SUCCESS(rv, rv);
++        rv = localDir->AppendRelativeNativePath(nsDependentCString(".local"));
++        NS_ENSURE_SUCCESS(rv, rv);
++        rv = localDir->Exists(&exists);
++        if (NS_SUCCEEDED(rv) && !exists) {
++          rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0755);
++          NS_ENSURE_SUCCESS(rv, rv);
++        }
++        rv = localDir->AppendRelativeNativePath(nsDependentCString("share"));
++        NS_ENSURE_SUCCESS(rv, rv);
++        rv = localDir->Exists(&exists);
++        if (NS_SUCCEEDED(rv) && !exists) {
++          rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0755);
++        }
++      }
++      else {
++        rv = NS_NewNativeLocalFile(nsDependentCString(xdghomedir), true,
++                               getter_AddRefs(localDir));
++      }
++      NS_ENSURE_SUCCESS(rv, rv);
++
++      rv = localDir->AppendRelativeNativePath(nsDependentCString("mozilla"));
++      NS_ENSURE_SUCCESS(rv, rv);
++      rv = localDir->Exists(&exists);
++      NS_ENSURE_SUCCESS(rv, rv);
++      if (NS_SUCCEEDED(rv) && !exists) {
++        rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
++        NS_ENSURE_SUCCESS(rv, rv);
++      }
++    }
+   }
+ #else
+ #error "Don't know how to get product dir on your platform"
+@@ -1734,20 +1777,12 @@ nsXREDirProvider::AppendSysUserExtensionPath(nsIFile* aFile)
+ 
+ #if defined (XP_MACOSX) || defined(XP_WIN)
+ 
+-  static const char* const sXR = "Mozilla";
+-  rv = aFile->AppendNative(nsDependentCString(sXR));
+-  NS_ENSURE_SUCCESS(rv, rv);
+-
+   static const char* const sExtensions = "Extensions";
+   rv = aFile->AppendNative(nsDependentCString(sExtensions));
+   NS_ENSURE_SUCCESS(rv, rv);
+ 
+ #elif defined(XP_UNIX)
+ 
+-  static const char* const sXR = ".mozilla";
+-  rv = aFile->AppendNative(nsDependentCString(sXR));
+-  NS_ENSURE_SUCCESS(rv, rv);
+-
+   static const char* const sExtensions = "extensions";
+   rv = aFile->AppendNative(nsDependentCString(sExtensions));
+   NS_ENSURE_SUCCESS(rv, rv);
+@@ -1767,20 +1802,12 @@ nsXREDirProvider::AppendSysUserExtensionsDevPath(nsIFile* aFile)
+ 
+ #if defined (XP_MACOSX) || defined(XP_WIN)
+ 
+-  static const char* const sXR = "Mozilla";
+-  rv = aFile->AppendNative(nsDependentCString(sXR));
+-  NS_ENSURE_SUCCESS(rv, rv);
+-
+   static const char* const sExtensions = "SystemExtensionsDev";
+   rv = aFile->AppendNative(nsDependentCString(sExtensions));
+   NS_ENSURE_SUCCESS(rv, rv);
+ 
+ #elif defined(XP_UNIX)
+ 
+-  static const char* const sXR = ".mozilla";
+-  rv = aFile->AppendNative(nsDependentCString(sXR));
+-  NS_ENSURE_SUCCESS(rv, rv);
+-
+   static const char* const sExtensions = "systemextensionsdev";
+   rv = aFile->AppendNative(nsDependentCString(sExtensions));
+   NS_ENSURE_SUCCESS(rv, rv);
+@@ -1843,10 +1870,6 @@ nsXREDirProvider::AppendProfilePath(nsIFile* aFile, bool aLocal)
+   NS_ENSURE_SUCCESS(rv, rv);
+ #elif defined(XP_UNIX)
+   nsAutoCString folder;
+-  // Make it hidden (by starting with "."), except when local (the
+-  // profile is already under ~/.cache or XDG_CACHE_HOME).
+-  if (!aLocal)
+-    folder.Assign('.');
+ 
+   if (!profile.IsEmpty()) {
+     // Skip any leading path characters
+@@ -1869,8 +1892,12 @@ nsXREDirProvider::AppendProfilePath(nsIFile* aFile, bool aLocal)
+       folder.Append(vendor);
+       ToLowerCase(folder);
+ 
+-      rv = aFile->AppendNative(folder);
+-      NS_ENSURE_SUCCESS(rv, rv);
++      // Keep the 'mozilla' path for cache:
++      // Use ${XDG_DATA_HOME:-$HOME/.cache}/mozilla/firefox
++      if (aLocal) {
++        rv = aFile->AppendNative(folder);
++        NS_ENSURE_SUCCESS(rv, rv);
++      }
+ 
+       folder.Truncate();
+     }
+diff --git a/xpcom/io/nsAppFileLocationProvider.cpp b/xpcom/io/nsAppFileLocationProvider.cpp
+index 45628ed7a..dfe517c77 100644
+--- a/xpcom/io/nsAppFileLocationProvider.cpp
++++ b/xpcom/io/nsAppFileLocationProvider.cpp
+@@ -252,7 +252,7 @@ nsAppFileLocationProvider::CloneMozBinDirectory(nsIFile** aLocalFile)
+ //----------------------------------------------------------------------------------------
+ // GetProductDirectory - Gets the directory which contains the application data folder
+ //
+-// UNIX   : ~/.mozilla/
++// UNIX   : ~/.mozilla/ or ${XDG_DATA_HOME:-~/.local/share}/mozilla
+ // WIN    : <Application Data folder on user's machine>\Mozilla
+ // Mac    : :Documents:Mozilla:
+ //----------------------------------------------------------------------------------------
+@@ -297,19 +297,80 @@ nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
+     return rv;
+   }
+ #elif defined(XP_UNIX)
+-  rv = NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), true,
++  const char* homeDir = PR_GetEnv("HOME");
++  /* check old config ~/.mozilla */
++  rv = NS_NewNativeLocalFile(nsDependentCString(homeDir), true,
+                              getter_AddRefs(localDir));
+   if (NS_FAILED(rv)) {
+     return rv;
+   }
++  rv = localDir->AppendRelativeNativePath(nsDependentCString(".mozilla"));
++  if (NS_FAILED(rv)) {
++    return rv;
++  }
++  rv = localDir->Exists(&exists);
++  if (NS_FAILED(rv)) {
++    return rv;
++  }
++  /* otherwise, use new config */
++  if (!exists) {
++    const char* xdghomedir = PR_GetEnv("XDG_DATA_HOME");
++    if (!xdghomedir || !*xdghomedir) {
++      /* XDG_DATA_HOME=$HOME/.local/share */
++      rv = NS_NewNativeLocalFile(nsDependentCString(homeDir), true,
++                                 getter_AddRefs(localDir));
++      if (NS_FAILED(rv)) {
++        return rv;
++      }
++      rv = localDir->AppendRelativeNativePath(nsDependentCString(".local"));
++      if (NS_FAILED(rv)) {
++        return rv;
++      }
++      rv = localDir->Exists(&exists);
++      if (NS_SUCCEEDED(rv) && !exists) {
++        rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0755);
++        if (NS_FAILED(rv)) {
++          return rv;
++        }
++      }
++      rv = localDir->AppendRelativeNativePath(nsDependentCString("share"));
++      if (NS_FAILED(rv)) {
++        return rv;
++      }
++      rv = localDir->Exists(&exists);
++      if (NS_SUCCEEDED(rv) && !exists) {
++        rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0755);
++      }
++    }
++    else {
++      rv = NS_NewNativeLocalFile(nsDependentCString(xdghomedir), true,
++                                 getter_AddRefs(localDir));
++    }
++    if (NS_FAILED(rv)) {
++      return rv;
++    }
++    rv = localDir->AppendRelativeNativePath(nsDependentCString("mozilla"));
++    if (NS_FAILED(rv)) {
++      return rv;
++    }
++  }
+ #else
+ #error dont_know_how_to_get_product_dir_on_your_platform
+ #endif
+ 
++#if !defined(XP_UNIX) || defined(XP_MACOSX)
++  // Since we have to check for legacy configuration, we have
++  // the complete path for Linux already, so this is not
++  // needed. If we stop checking for legacy at some point,
++  // then we can change this to not be protected by
++  // this clause.
+   rv = localDir->AppendRelativeNativePath(DEFAULT_PRODUCT_DIR);
++
+   if (NS_FAILED(rv)) {
+     return rv;
+   }
++#endif
++
+   rv = localDir->Exists(&exists);
+ 
+   if (NS_SUCCEEDED(rv) && !exists) {
+@@ -329,7 +390,7 @@ nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
+ //----------------------------------------------------------------------------------------
+ // GetDefaultUserProfileRoot - Gets the directory which contains each user profile dir
+ //
+-// UNIX   : ~/.mozilla/
++// UNIX   : ~/.mozilla/ or ${XDG_DATA_HOME:-~/.local/share}/mozilla
+ // WIN    : <Application Data folder on user's machine>\Mozilla\Profiles
+ // Mac    : :Documents:Mozilla:Profiles:
+ //----------------------------------------------------------------------------------------