From 209307a0375703e9b157c26061119db7653d4866 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 30 Sep 2014 21:26:26 -0400 Subject: [PATCH] Bug 1072991. Make sure to set the right base URI on the document clones we create for printing. r=smaug --- content/base/src/nsDocument.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 8436d32137b2..8c0444e3f20d 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -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 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 =