Fixing bug 606058. Given XUL overlay documents the principals of the containing document. r=bzbarsky@mit.edu, a=blocker

This commit is contained in:
Johnny Stenback 2011-01-06 18:07:46 -08:00
parent 9f0221e128
commit a58c641c00

View File

@ -2776,7 +2776,19 @@ nsXULDocument::LoadOverlayInternal(nsIURI* aURI, PRBool aIsDynamic,
NS_RELEASE(parserObserver);
nsCOMPtr<nsILoadGroup> group = do_QueryReferent(mDocumentLoadGroup);
rv = NS_OpenURI(listener, nsnull, aURI, nsnull, group);
nsCOMPtr<nsIChannel> channel;
rv = NS_NewChannel(getter_AddRefs(channel), aURI, nsnull, group);
if (NS_SUCCEEDED(rv)) {
// Set the owner of the channel to be our principal so
// that the overlay's JSObjects etc end up being created
// with the right principal and in the correct
// compartment.
channel->SetOwner(NodePrincipal());
rv = channel->AsyncOpen(listener, nsnull);
}
if (NS_FAILED(rv)) {
// Abandon this prototype
mCurrentPrototype = nsnull;
@ -4531,7 +4543,7 @@ nsXULDocument::ParserObserver::OnStartRequest(nsIRequest *request,
secMan->GetChannelPrincipal(channel, getter_AddRefs(principal));
// Failure there is ok -- it'll just set a (safe) null principal
mPrototype->SetDocumentPrincipal(principal);
mPrototype->SetDocumentPrincipal(principal);
}
// Make sure to avoid cycles