Revert "Bug 1209162 - Create OriginAttributes subtypes. IGNORE IDL r=sicking."

This commit is contained in:
2023-03-24 22:59:15 +08:00
parent 21cd830e68
commit 03c3a2ab87
79 changed files with 318 additions and 600 deletions
+11 -20
View File
@@ -9446,8 +9446,7 @@ nsresult
nsDocShell::CreatePrincipalFromReferrer(nsIURI* aReferrer,
nsIPrincipal** aResult)
{
PrincipalOriginAttributes attrs;
attrs.InheritFromDocShellToDoc(GetOriginAttributes(), aReferrer);
OriginAttributes attrs = GetOriginAttributes();
nsCOMPtr<nsIPrincipal> prin =
BasePrincipal::CreateCodebasePrincipal(aReferrer, attrs);
prin.forget(aResult);
@@ -13891,19 +13890,13 @@ nsDocShell::GetAppId(uint32_t* aAppId)
return parent->GetAppId(aAppId);
}
DocShellOriginAttributes
OriginAttributes
nsDocShell::GetOriginAttributes()
{
DocShellOriginAttributes attrs;
OriginAttributes attrs;
RefPtr<nsDocShell> parent = GetParentDocshell();
if (parent) {
nsCOMPtr<nsIPrincipal> parentPrin = parent->GetDocument()->NodePrincipal();
PrincipalOriginAttributes poa = BasePrincipal::Cast(parentPrin)->OriginAttributesRef();
attrs.InheritFromDocToChildDocShell(poa);
} else {
// This is the topmost docshell, so we get the mSignedPkg attribute if it is
// set before.
attrs.mSignedPkg = mSignedPkg;
attrs.InheritFromDocShellParent(parent->GetOriginAttributes());
}
if (mOwnOrContainingAppId != nsIScriptSecurityManager::UNKNOWN_APP_ID) {
@@ -13914,6 +13907,9 @@ nsDocShell::GetOriginAttributes()
attrs.mInBrowser = true;
}
// Bug 1209162 will address the inheritance of each attributes.
attrs.mSignedPkg = mSignedPkg;
return attrs;
}
@@ -13923,7 +13919,8 @@ nsDocShell::GetOriginAttributes(JS::MutableHandle<JS::Value> aVal)
JSContext* cx = nsContentUtils::GetCurrentJSContext();
MOZ_ASSERT(cx);
bool ok = ToJSValue(cx, GetOriginAttributes(), aVal);
OriginAttributes attrs = GetOriginAttributes();
bool ok = ToJSValue(cx, attrs, aVal);
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
return NS_OK;
}
@@ -14122,8 +14119,7 @@ nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNonSubresourceReques
}
if (aIsNonSubresourceRequest) {
PrincipalOriginAttributes attrs;
attrs.InheritFromDocShellToDoc(GetOriginAttributes(), aURI);
OriginAttributes attrs(GetAppId(), GetIsInBrowserElement());
*aShouldIntercept = swm->IsAvailable(attrs, aURI);
return NS_OK;
}
@@ -14219,12 +14215,7 @@ nsDocShell::ChannelIntercepted(nsIInterceptedChannel* aChannel,
bool isReload = mLoadType & LOAD_CMD_RELOAD;
nsCOMPtr<nsIURI> uri;
rv = channel->GetURI(getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
PrincipalOriginAttributes attrs;
attrs.InheritFromDocShellToDoc(GetOriginAttributes(), uri);
OriginAttributes attrs(GetAppId(), GetIsInBrowserElement());
ErrorResult error;
nsCOMPtr<nsIRunnable> runnable =