зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 237acf2879f6 (bug 1407428) for frequent crashes, e.g. in xpcshell's test_bug248970_cookie.js. r=backout on a CLOSED TREE
--HG-- extra : amend_source : 1ccac4fb953566239cba8db7d6f8bdca4ce48b35
This commit is contained in:
Родитель
324f132c98
Коммит
11a2b8ef67
|
@ -100,14 +100,15 @@ ExpandedPrincipal::SubsumesInternal(nsIPrincipal* aOther,
|
|||
{
|
||||
// If aOther is an ExpandedPrincipal too, we break it down into its component
|
||||
// nsIPrincipals, and check subsumes on each one.
|
||||
if (Cast(aOther)->Is<ExpandedPrincipal>()) {
|
||||
auto* expanded = Cast(aOther)->As<ExpandedPrincipal>();
|
||||
|
||||
for (auto& other : expanded->WhiteList()) {
|
||||
nsCOMPtr<nsIExpandedPrincipal> expanded = do_QueryInterface(aOther);
|
||||
if (expanded) {
|
||||
nsTArray< nsCOMPtr<nsIPrincipal> >* otherList;
|
||||
expanded->GetWhiteList(&otherList);
|
||||
for (uint32_t i = 0; i < otherList->Length(); ++i){
|
||||
// Use SubsumesInternal rather than Subsumes here, since OriginAttribute
|
||||
// checks are only done between non-expanded sub-principals, and we don't
|
||||
// need to incur the extra virtual call overhead.
|
||||
if (!SubsumesInternal(other, aConsideration)) {
|
||||
if (!SubsumesInternal((*otherList)[i], aConsideration)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -150,10 +151,11 @@ ExpandedPrincipal::GetURI(nsIURI** aURI)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
const nsTArray<nsCOMPtr<nsIPrincipal>>&
|
||||
ExpandedPrincipal::WhiteList()
|
||||
NS_IMETHODIMP
|
||||
ExpandedPrincipal::GetWhiteList(nsTArray<nsCOMPtr<nsIPrincipal> >** aWhiteList)
|
||||
{
|
||||
return mPrincipals;
|
||||
*aWhiteList = &mPrincipals;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -42,7 +42,7 @@ interface nsIDOMDocument;
|
|||
|
||||
[ptr] native JSContext(JSContext);
|
||||
[ptr] native JSPrincipals(JSPrincipals);
|
||||
[ref] native PrincipalArray(const nsTArray<nsCOMPtr<nsIPrincipal>>);
|
||||
[ptr] native PrincipalArray(nsTArray<nsCOMPtr<nsIPrincipal> >);
|
||||
[ref] native const_OriginAttributes(const mozilla::OriginAttributes);
|
||||
|
||||
[scriptable, builtinclass, uuid(f75f502d-79fd-48be-a079-e5a7b8f80c8b)]
|
||||
|
@ -340,6 +340,5 @@ interface nsIExpandedPrincipal : nsISupports
|
|||
* Note: this list is not reference counted, it is shared, so
|
||||
* should not be changed and should only be used ephemerally.
|
||||
*/
|
||||
[noscript, notxpcom, nostdcall]
|
||||
PrincipalArray WhiteList();
|
||||
[noscript] readonly attribute PrincipalArray whiteList;
|
||||
};
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "nspr.h"
|
||||
#include "nsJSPrincipals.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "ExpandedPrincipal.h"
|
||||
#include "SystemPrincipal.h"
|
||||
#include "NullPrincipal.h"
|
||||
#include "DomainPolicy.h"
|
||||
|
@ -669,11 +668,12 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal,
|
|||
nsCOMPtr<nsIURI> sourceURI;
|
||||
aPrincipal->GetURI(getter_AddRefs(sourceURI));
|
||||
if (!sourceURI) {
|
||||
auto* basePrin = BasePrincipal::Cast(aPrincipal);
|
||||
if (basePrin->Is<ExpandedPrincipal>()) {
|
||||
auto expanded = basePrin->As<ExpandedPrincipal>();
|
||||
for (auto& prin : expanded->WhiteList()) {
|
||||
nsresult rv = CheckLoadURIWithPrincipal(prin,
|
||||
nsCOMPtr<nsIExpandedPrincipal> expanded = do_QueryInterface(aPrincipal);
|
||||
if (expanded) {
|
||||
nsTArray< nsCOMPtr<nsIPrincipal> > *whiteList;
|
||||
expanded->GetWhiteList(&whiteList);
|
||||
for (uint32_t i = 0; i < whiteList->Length(); ++i) {
|
||||
nsresult rv = CheckLoadURIWithPrincipal((*whiteList)[i],
|
||||
aTargetURI,
|
||||
aFlags);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
|
|
@ -2494,9 +2494,11 @@ nsDocument::MaybeDowngradePrincipal(nsIPrincipal* aPrincipal)
|
|||
if (basePrin->Is<ExpandedPrincipal>()) {
|
||||
auto* expanded = basePrin->As<ExpandedPrincipal>();
|
||||
|
||||
MOZ_ASSERT(expanded->WhiteList().Length() > 0);
|
||||
nsTArray<nsCOMPtr<nsIPrincipal>>* whitelist;
|
||||
MOZ_ALWAYS_SUCCEEDS(expanded->GetWhiteList(&whitelist));
|
||||
MOZ_ASSERT(whitelist->Length() > 0);
|
||||
|
||||
return do_AddRef(expanded->WhiteList().LastElement().get());
|
||||
return do_AddRef(whitelist->LastElement().get());
|
||||
}
|
||||
|
||||
if (!sChromeInContentPrefCached) {
|
||||
|
|
|
@ -2499,11 +2499,16 @@ XMLHttpRequestMainThread::CreateChannel()
|
|||
nsCOMPtr<nsIPrincipal> resultingDocumentPrincipal(mPrincipal);
|
||||
nsCOMPtr<nsIExpandedPrincipal> ep = do_QueryInterface(mPrincipal);
|
||||
if (ep) {
|
||||
nsTArray<nsCOMPtr<nsIPrincipal>>* whitelist = nullptr;
|
||||
ep->GetWhiteList(&whitelist);
|
||||
if (!whitelist) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
MOZ_ASSERT(!(secFlags & nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS));
|
||||
bool dataInherits = (secFlags &
|
||||
(nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS |
|
||||
nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS)) != 0;
|
||||
for (const auto& principal : ep->WhiteList()) {
|
||||
for (const auto& principal : *whitelist) {
|
||||
if (NS_SUCCEEDED(principal->CheckMayLoad(mRequestURL, false, dataInherits))) {
|
||||
resultingDocumentPrincipal = principal;
|
||||
break;
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#include "nsPrintfCString.h"
|
||||
#include "mozilla/AbstractThread.h"
|
||||
#include "ContentPrincipal.h"
|
||||
#include "ExpandedPrincipal.h"
|
||||
|
||||
static nsPermissionManager *gPermissionManager = nullptr;
|
||||
|
||||
|
@ -2234,13 +2233,16 @@ nsPermissionManager::CommonTestPermissionInternal(nsIPrincipal* aPrincipal,
|
|||
|
||||
// For expanded principals, we want to iterate over the whitelist and see
|
||||
// if the permission is granted for any of them.
|
||||
auto* basePrin = BasePrincipal::Cast(aPrincipal);
|
||||
if (basePrin->Is<ExpandedPrincipal>()) {
|
||||
auto ep = basePrin->As<ExpandedPrincipal>();
|
||||
for (auto& prin : ep->WhiteList()) {
|
||||
nsCOMPtr<nsIExpandedPrincipal> ep = do_QueryInterface(aPrincipal);
|
||||
if (ep) {
|
||||
nsTArray<nsCOMPtr<nsIPrincipal>>* whitelist;
|
||||
nsresult rv = ep->GetWhiteList(&whitelist);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
for (size_t i = 0; i < whitelist->Length(); ++i) {
|
||||
uint32_t perm;
|
||||
nsresult rv = CommonTestPermission(prin, aType, &perm,
|
||||
aExactHostMatch, aIncludingSession);
|
||||
rv = CommonTestPermission(whitelist->ElementAt(i), aType, &perm,
|
||||
aExactHostMatch, aIncludingSession);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (perm == nsIPermissionManager::ALLOW_ACTION) {
|
||||
*aPermission = perm;
|
||||
|
|
|
@ -192,15 +192,18 @@ PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
|
|||
}
|
||||
|
||||
// might be an expanded principal
|
||||
auto* basePrin = BasePrincipal::Cast(aPrincipal);
|
||||
if (basePrin->Is<ExpandedPrincipal>()) {
|
||||
auto* expanded = basePrin->As<ExpandedPrincipal>();
|
||||
nsCOMPtr<nsIExpandedPrincipal> expanded =
|
||||
do_QueryInterface(aPrincipal);
|
||||
|
||||
if (expanded) {
|
||||
nsTArray<PrincipalInfo> whitelistInfo;
|
||||
PrincipalInfo info;
|
||||
|
||||
for (auto& prin : expanded->WhiteList()) {
|
||||
rv = PrincipalToPrincipalInfo(prin, &info);
|
||||
nsTArray< nsCOMPtr<nsIPrincipal> >* whitelist;
|
||||
MOZ_ALWAYS_SUCCEEDS(expanded->GetWhiteList(&whitelist));
|
||||
|
||||
for (uint32_t i = 0; i < whitelist->Length(); i++) {
|
||||
rv = PrincipalToPrincipalInfo((*whitelist)[i], &info);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -583,7 +583,9 @@ IsWebExtensionContentScript(BasePrincipal* principal, nsAString& addonId)
|
|||
|
||||
auto expanded = principal->As<ExpandedPrincipal>();
|
||||
|
||||
for (auto& prin : expanded->WhiteList()) {
|
||||
nsTArray<nsCOMPtr<nsIPrincipal>>* principals;
|
||||
expanded->GetWhiteList(&principals);
|
||||
for (auto prin : *principals) {
|
||||
if (IsWebExtensionPrincipal(prin, addonId)) {
|
||||
return true;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче