Bug 1072991. Make sure to set the right base URI on the document clones we create for printing. r=smaug

This commit is contained in:
Boris Zbarsky 2014-09-30 21:26:26 -04:00
Родитель b7f87dd74c
Коммит 209307a037
1 изменённых файлов: 12 добавлений и 8 удалений

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

@ -9178,14 +9178,6 @@ nsDocument::CloneDocHelper(nsDocument* clone) const
nsresult rv = clone->Init();
NS_ENSURE_SUCCESS(rv, rv);
// Set URI/principal
clone->nsDocument::SetDocumentURI(nsIDocument::GetDocumentURI());
clone->SetChromeXHRDocURI(mChromeXHRDocURI);
// Must set the principal first, since SetBaseURI checks it.
clone->SetPrincipal(NodePrincipal());
clone->mDocumentBaseURI = mDocumentBaseURI;
clone->SetChromeXHRDocBaseURI(mChromeXHRDocBaseURI);
if (mCreatingStaticClone) {
nsCOMPtr<nsILoadGroup> loadGroup;
@ -9210,6 +9202,18 @@ nsDocument::CloneDocHelper(nsDocument* clone) const
clone->SetContainer(mDocumentContainer);
}
// Now ensure that our clone has the same URI, base URI, and principal as us.
// We do this after the mCreatingStaticClone block above, because that block
// can set the base URI to an incorrect value in cases when base URI
// information came from the channel. So we override explicitly, and do it
// for all these properties, in case ResetToURI messes with any of the rest of
// them.
clone->nsDocument::SetDocumentURI(nsIDocument::GetDocumentURI());
clone->SetChromeXHRDocURI(mChromeXHRDocURI);
clone->SetPrincipal(NodePrincipal());
clone->mDocumentBaseURI = mDocumentBaseURI;
clone->SetChromeXHRDocBaseURI(mChromeXHRDocBaseURI);
// Set scripting object
bool hasHadScriptObject = true;
nsIScriptGlobalObject* scriptObject =