Bug 1300851 - Don't use expanded principals when creating the about:blank content viewer eagerly; r=bzbarsky

This commit is contained in:
Ehsan Akhgari 2016-09-07 19:30:36 -04:00
Родитель ed81ee1595
Коммит 67f68a06ad
2 изменённых файлов: 9 добавлений и 1 удалений

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

@ -2162,6 +2162,7 @@ nsGlobalWindow::SetInitialPrincipalToSubject()
// We should never create windows with an expanded principal.
// If we have a system principal, make sure we're not using it for a content
// docshell.
// NOTE: Please keep this logic in sync with nsWebShellWindow::Initialize().
if (nsContentUtils::IsExpandedPrincipal(newWindowPrincipal) ||
(nsContentUtils::IsSystemPrincipal(newWindowPrincipal) &&
GetDocShell()->ItemType() != nsIDocShellTreeItem::typeChrome)) {

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

@ -214,8 +214,15 @@ nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent,
// 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.
// Note that we don't accept expanded principals here, similar to
// SetInitialPrincipalToSubject.
if (nsContentUtils::IsInitialized()) { // Sometimes this happens really early See bug 793370.
rv = mDocShell->CreateAboutBlankContentViewer(nsContentUtils::SubjectPrincipalOrSystemIfNativeCaller());
MOZ_ASSERT(mDocShell->ItemType() == nsIDocShellTreeItem::typeChrome);
nsCOMPtr<nsIPrincipal> principal = nsContentUtils::SubjectPrincipalOrSystemIfNativeCaller();
if (nsContentUtils::IsExpandedPrincipal(principal)) {
principal = nullptr;
}
rv = mDocShell->CreateAboutBlankContentViewer(principal);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc = mDocShell ? mDocShell->GetDocument() : nullptr;
NS_ENSURE_TRUE(!!doc, NS_ERROR_FAILURE);