зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1275485 - Put back changes in bug 1260766 that sets userContextId in frame loader. r=baku
This commit is contained in:
Родитель
31350135f5
Коммит
0a95fce4b2
|
@ -962,8 +962,25 @@ nsFrameLoader::SwapWithOtherRemoteLoader(nsFrameLoader* aOther,
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
if (mRemoteBrowser->OriginAttributesRef() !=
|
||||
aOther->mRemoteBrowser->OriginAttributesRef()) {
|
||||
// When we swap docShells, maybe we have to deal with a new page created just
|
||||
// for this operation. In this case, the browser code should already have set
|
||||
// the correct userContextId attribute value in the owning XULElement, but our
|
||||
// docShell, that has been created way before) doesn't know that that
|
||||
// happened.
|
||||
// This is the reason why now we must retrieve the correct value from the
|
||||
// usercontextid attribute before comparing our originAttributes with the
|
||||
// other one.
|
||||
DocShellOriginAttributes ourOriginAttributes =
|
||||
mRemoteBrowser->OriginAttributesRef();
|
||||
rv = PopulateUserContextIdFromAttribute(ourOriginAttributes);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
DocShellOriginAttributes otherOriginAttributes =
|
||||
aOther->mRemoteBrowser->OriginAttributesRef();
|
||||
rv = aOther->PopulateUserContextIdFromAttribute(otherOriginAttributes);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (ourOriginAttributes != otherOriginAttributes) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
@ -1343,8 +1360,25 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
if (ourDocshell->GetOriginAttributes() !=
|
||||
otherDocshell->GetOriginAttributes()) {
|
||||
// When we swap docShells, maybe we have to deal with a new page created just
|
||||
// for this operation. In this case, the browser code should already have set
|
||||
// the correct userContextId attribute value in the owning XULElement, but our
|
||||
// docShell, that has been created way before) doesn't know that that
|
||||
// happened.
|
||||
// This is the reason why now we must retrieve the correct value from the
|
||||
// usercontextid attribute before comparing our originAttributes with the
|
||||
// other one.
|
||||
DocShellOriginAttributes ourOriginAttributes =
|
||||
ourDocshell->GetOriginAttributes();
|
||||
rv = PopulateUserContextIdFromAttribute(ourOriginAttributes);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
DocShellOriginAttributes otherOriginAttributes =
|
||||
otherDocshell->GetOriginAttributes();
|
||||
rv = aOther->PopulateUserContextIdFromAttribute(otherOriginAttributes);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (ourOriginAttributes != otherOriginAttributes) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
@ -2107,13 +2141,9 @@ nsFrameLoader::MaybeCreateDocShell()
|
|||
}
|
||||
|
||||
// Grab the userContextId from owner if XUL
|
||||
nsAutoString userContextIdStr;
|
||||
if ((namespaceID == kNameSpaceID_XUL) &&
|
||||
mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::usercontextid, userContextIdStr) &&
|
||||
!userContextIdStr.IsEmpty()) {
|
||||
nsresult rv;
|
||||
attrs.mUserContextId = userContextIdStr.ToInteger(&rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsresult rv = PopulateUserContextIdFromAttribute(attrs);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsDocShell::Cast(mDocShell)->SetOriginAttributes(attrs);
|
||||
|
@ -3373,3 +3403,24 @@ nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext,
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFrameLoader::PopulateUserContextIdFromAttribute(DocShellOriginAttributes& aAttr)
|
||||
{
|
||||
if (aAttr.mUserContextId ==
|
||||
nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID) {
|
||||
// Grab the userContextId from owner if XUL
|
||||
nsAutoString userContextIdStr;
|
||||
int32_t namespaceID = mOwnerContent->GetNameSpaceID();
|
||||
if ((namespaceID == kNameSpaceID_XUL) &&
|
||||
mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::usercontextid,
|
||||
userContextIdStr) &&
|
||||
!userContextIdStr.IsEmpty()) {
|
||||
nsresult rv;
|
||||
aAttr.mUserContextId = userContextIdStr.ToInteger(&rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,9 @@ class nsIDocShellTreeOwner;
|
|||
class mozIApplication;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class DocShellOriginAttributes;
|
||||
|
||||
namespace dom {
|
||||
class ContentParent;
|
||||
class PBrowserParent;
|
||||
|
@ -340,6 +343,9 @@ private:
|
|||
};
|
||||
void MaybeUpdatePrimaryTabParent(TabParentChange aChange);
|
||||
|
||||
nsresult
|
||||
PopulateUserContextIdFromAttribute(mozilla::DocShellOriginAttributes& aAttr);
|
||||
|
||||
nsCOMPtr<nsIDocShell> mDocShell;
|
||||
nsCOMPtr<nsIURI> mURIToLoad;
|
||||
mozilla::dom::Element* mOwnerContent; // WEAK
|
||||
|
|
Загрузка…
Ссылка в новой задаче