Bug 793370 - crash in nsWebShellWindow::Initialize, r=smaug+bz
authorbobbyholley+bmo@gmail.com
Sun, 30 Sep 2012 22:10:37 +0300
changeset 108795 a4ea3c56646b4a6c8e811c2bd2040928bcd42241
parent 108794 0df33af01ceeb06e16ce554ea1ce499260439178
child 108796 490b19dde4762606c38ced844a2b29317d4a7071
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewerssmaug
bugs793370
milestone18.0a1
Bug 793370 - crash in nsWebShellWindow::Initialize, r=smaug+bz
xpfe/appshell/src/nsWebShellWindow.cpp
--- a/xpfe/appshell/src/nsWebShellWindow.cpp
+++ b/xpfe/appshell/src/nsWebShellWindow.cpp
@@ -199,27 +199,28 @@ nsresult nsWebShellWindow::Initialize(ns
 
   // Eagerly create an about:blank content viewer with the right principal here,
   // rather than letting it happening in the upcoming call to
   // SetInitialPrincipalToSubject. This avoids creating the about:blank document
   // and then blowing it away with a second one, which can cause problems for the
   // top-level chrome window case. See bug 789773.
   nsCOMPtr<nsIScriptSecurityManager> ssm =
     do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
-  MOZ_ASSERT(NS_SUCCEEDED(rv) && ssm);
-  nsCOMPtr<nsIPrincipal> principal;
-  ssm->GetSubjectPrincipal(getter_AddRefs(principal));
-  if (!principal) {
-    ssm->GetSystemPrincipal(getter_AddRefs(principal));
+  if (ssm) { // Sometimes this happens really early  See bug 793370.
+    nsCOMPtr<nsIPrincipal> principal;
+    ssm->GetSubjectPrincipal(getter_AddRefs(principal));
+    if (!principal) {
+      ssm->GetSystemPrincipal(getter_AddRefs(principal));
+    }
+    rv = mDocShell->CreateAboutBlankContentViewer(principal);
+    NS_ENSURE_SUCCESS(rv, rv);
+    nsCOMPtr<nsIDocument> doc = do_GetInterface(mDocShell);
+    NS_ENSURE_TRUE(!!doc, NS_ERROR_FAILURE);
+    doc->SetIsInitialDocument(true);
   }
-  rv = mDocShell->CreateAboutBlankContentViewer(principal);
-  NS_ENSURE_SUCCESS(rv, rv);
-  nsCOMPtr<nsIDocument> doc = do_GetInterface(mDocShell);
-  NS_ENSURE_TRUE(!!doc, NS_ERROR_FAILURE);
-  doc->SetIsInitialDocument(true);
 
   if (nullptr != aUrl)  {
     nsCString tmpStr;
 
     rv = aUrl->GetSpec(tmpStr);
     if (NS_FAILED(rv)) return rv;
 
     NS_ConvertUTF8toUTF16 urlString(tmpStr);