Bug 1533405 - Do not create the hidden window if it's too early on startup or during shutdown. r=mossop a=pascalc
authorFelipe Gomes <felipc@gmail.com>
Wed, 20 Mar 2019 19:35:59 +0000
changeset 525895 39a03fc4bac62ce4def8cd2cdaffe350b3df2417
parent 525894 626d4588cc90b132a7005c700a2b094c01a10267
child 525896 a3b5dd595e17ef9b32ec4c806560362ca2347526
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop, pascalc
bugs1533405
milestone67.0
Bug 1533405 - Do not create the hidden window if it's too early on startup or during shutdown. r=mossop a=pascalc Differential Revision: https://phabricator.services.mozilla.com/D24252
xpfe/appshell/nsAppShellService.cpp
--- a/xpfe/appshell/nsAppShellService.cpp
+++ b/xpfe/appshell/nsAppShellService.cpp
@@ -21,18 +21,20 @@
 #include "nsWebShellWindow.h"
 
 #include "nsWidgetInitData.h"
 #include "nsWidgetsCID.h"
 #include "nsIWidget.h"
 #include "nsIRequestObserver.h"
 #include "nsIEmbeddingSiteWindow.h"
 
+#include "nsAppDirectoryServiceDefs.h"
 #include "nsAppShellService.h"
 #include "nsContentUtils.h"
+#include "nsDirectoryServiceUtils.h"
 #include "nsThreadUtils.h"
 #include "nsISupportsPrimitives.h"
 #include "nsILoadContext.h"
 #include "nsIWebNavigation.h"
 #include "nsIWindowlessBrowser.h"
 
 #include "mozilla/Attributes.h"
 #include "mozilla/Preferences.h"
@@ -104,16 +106,28 @@ void nsAppShellService::EnsurePrivateHid
   }
 }
 
 nsresult nsAppShellService::CreateHiddenWindowHelper(bool aIsPrivate) {
   if (!XRE_IsParentProcess()) {
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 
+  if (mXPCOMShuttingDown) {
+    return NS_ERROR_FAILURE;
+  }
+
+  nsCOMPtr<nsIFile> profileDir;
+  NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
+                         getter_AddRefs(profileDir));
+  if (!profileDir) {
+    // This is too early on startup to create the hidden window
+    return NS_ERROR_FAILURE;
+  }
+
   nsresult rv;
   int32_t initialHeight = 100, initialWidth = 100;
 
 #ifdef XP_MACOSX
   uint32_t chromeMask = 0;
   nsAutoCString prefVal;
   rv = Preferences::GetCString("browser.hiddenWindowChromeURL", prefVal);
   const char* hiddenWindowURL =