Bug 1334346 - DocGroup should be correct for static clone documents (print, print preview) (r=smaug)

MozReview-Commit-ID: f0LdbxSahb
This commit is contained in:
Bill McCloskey 2017-01-26 16:36:31 -08:00
parent 4640ca8852
commit c8c4ea2401

View File

@ -4527,6 +4527,7 @@ nsDocument::SetScopeObject(nsIGlobalObject* aGlobal)
if (NS_SUCCEEDED(rv)) {
MOZ_RELEASE_ASSERT(mDocGroup->MatchesKey(docGroupKey));
}
MOZ_RELEASE_ASSERT(mDocGroup->GetTabGroup() == tabgroup);
} else {
mDocGroup = tabgroup->AddDocument(docGroupKey, this);
MOZ_ASSERT(mDocGroup);
@ -9220,12 +9221,17 @@ nsDocument::CloneDocHelper(nsDocument* clone) const
clone->mDocumentBaseURI = mDocumentBaseURI;
clone->SetChromeXHRDocBaseURI(mChromeXHRDocBaseURI);
// Set scripting object
bool hasHadScriptObject = true;
nsIScriptGlobalObject* scriptObject =
GetScriptHandlingObject(hasHadScriptObject);
NS_ENSURE_STATE(scriptObject || !hasHadScriptObject);
if (scriptObject) {
if (mCreatingStaticClone) {
// If we're doing a static clone (print, print preview), then we're going to
// be setting a scope object after the clone. It's better to set it only
// once, so we don't do that here. However, we do want to act as if there is
// a script handling object. So we set mHasHadScriptHandlingObject.
clone->mHasHadScriptHandlingObject = true;
} else if (scriptObject) {
clone->SetScriptHandlingObject(scriptObject);
} else {
clone->SetScopeObject(GetScopeObject());