bug 603152 - Inner windows principals must remain constant. If we want to change them, change the inner window instead. r=bz

This commit is contained in:
Blake Kaplan 2010-09-17 14:54:41 -07:00
parent 2ce9a1fca4
commit b594d291ff
4 changed files with 24 additions and 8 deletions

View File

@ -852,6 +852,7 @@ NS_INTERFACE_MAP_BEGIN(nsDocShell)
NS_INTERFACE_MAP_ENTRY(nsIWebShellServices)
NS_INTERFACE_MAP_ENTRY(nsILinkHandler)
NS_INTERFACE_MAP_ENTRY(nsIClipboardCommands)
NS_INTERFACE_MAP_ENTRY(nsIDocShell_MOZILLA_2_0_BRANCH)
NS_INTERFACE_MAP_END_INHERITING(nsDocLoader)
///*****************************************************************************
@ -6463,6 +6464,12 @@ nsDocShell::CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
return rv;
}
NS_IMETHODIMP
nsDocShell::CreateAboutBlankContentViewer(nsIPrincipal *aPrincipal)
{
return CreateAboutBlankContentViewer(aPrincipal, nsnull);
}
PRBool
nsDocShell::CanSavePresentation(PRUint32 aLoadType,
nsIRequest *aNewRequest,

View File

@ -186,7 +186,8 @@ class nsDocShell : public nsDocLoader,
public nsILoadContext,
public nsIWebShellServices,
public nsILinkHandler,
public nsIClipboardCommands
public nsIClipboardCommands,
public nsIDocShell_MOZILLA_2_0_BRANCH
{
friend class nsDSURIContentListener;
@ -201,6 +202,7 @@ public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOCSHELL
NS_DECL_NSIDOCSHELL_MOZILLA_2_0_BRANCH
NS_DECL_NSIDOCSHELLTREEITEM
NS_DECL_NSIDOCSHELLTREENODE
NS_DECL_NSIDOCSHELLHISTORY

View File

@ -535,3 +535,12 @@ interface nsIDocShell : nsISupports
*/
readonly attribute unsigned long long historyID;
};
[uuid(5f7a2184-31b6-4d67-9c75-0c17477766e2)]
interface nsIDocShell_MOZILLA_2_0_BRANCH : nsISupports {
/**
* Create a new about:blank document and content viewer.
* @param aPrincipal the principal to use for the new document.
*/
void createAboutBlankContentViewer(in nsIPrincipal aPrincipal);
};

View File

@ -1469,7 +1469,7 @@ nsGlobalWindow::SetOpenerScriptPrincipal(nsIPrincipal* aPrincipal)
// Do NOT set mOpenerScriptPrincipal in this case, just to be safe.
return;
}
#ifdef DEBUG
// We better have an about:blank document loaded at this point. Otherwise,
// something is really weird.
@ -1479,13 +1479,11 @@ nsGlobalWindow::SetOpenerScriptPrincipal(nsIPrincipal* aPrincipal)
IsAboutBlank(mDoc->GetDocumentURI()),
"Unexpected original document");
#endif
// Set the opener principal on our document; given the above check, this
// is safe.
mDoc->SetPrincipal(aPrincipal);
nsCOMPtr<nsIDocShell_MOZILLA_2_0_BRANCH> ds(do_QueryInterface(GetDocShell()));
ds->CreateAboutBlankContentViewer(aPrincipal);
mDoc->SetIsInitialDocument(PR_TRUE);
}
mOpenerScriptPrincipal = aPrincipal;
}
nsIPrincipal*