Bug 789773 - Eagerly create the about:blank viewer in nsWebShellWindow::Initialize. r=bz

This commit is contained in:
Bobby Holley 2012-09-18 12:16:05 +02:00
Родитель ed9cc61270
Коммит 3616b91ce2
1 изменённых файлов: 20 добавлений и 0 удалений

Просмотреть файл

@ -59,6 +59,7 @@
#include "nsIScreen.h"
#include "nsIContent.h" // for menus
#include "nsIScriptSecurityManager.h"
// For calculating size
#include "nsIPresShell.h"
@ -196,6 +197,25 @@ nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent,
webProgress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_NETWORK);
}
// 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));
}
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;