зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1340163 - Introducing originNoSuffix as attribute in ContentPrincipalInfo, r=smaug
This commit is contained in:
Родитель
a1b8a7905d
Коммит
50f7937e84
|
@ -135,7 +135,10 @@ ReadSuffixAndSpec(JSStructuredCloneReader* aReader,
|
|||
}
|
||||
|
||||
nsAutoCString suffix;
|
||||
suffix.SetLength(suffixLength);
|
||||
if (!suffix.SetLength(suffixLength, fallible)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!JS_ReadBytes(aReader, suffix.BeginWriting(), suffixLength)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -144,7 +147,10 @@ ReadSuffixAndSpec(JSStructuredCloneReader* aReader,
|
|||
return false;
|
||||
}
|
||||
|
||||
aSpec.SetLength(specLength);
|
||||
if (!aSpec.SetLength(specLength, fallible)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!JS_ReadBytes(aReader, aSpec.BeginWriting(), specLength)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -195,7 +201,7 @@ ReadPrincipalInfo(JSStructuredCloneReader* aReader,
|
|||
return false;
|
||||
}
|
||||
|
||||
aInfo = ContentPrincipalInfo(attrs, spec);
|
||||
aInfo = ContentPrincipalInfo(attrs, void_t(), spec);
|
||||
} else {
|
||||
MOZ_CRASH("unexpected principal structured clone tag");
|
||||
}
|
||||
|
|
|
@ -1975,15 +1975,15 @@ ReadResponse(mozIStorageConnection* aConn, EntryId aEntryId,
|
|||
|
||||
aSavedResponseOut->mValue.principalInfo() = void_t();
|
||||
if (!serializedInfo.IsEmpty()) {
|
||||
nsAutoCString originNoSuffix;
|
||||
nsAutoCString specNoSuffix;
|
||||
OriginAttributes attrs;
|
||||
if (!attrs.PopulateFromOrigin(serializedInfo, originNoSuffix)) {
|
||||
if (!attrs.PopulateFromOrigin(serializedInfo, specNoSuffix)) {
|
||||
NS_WARNING("Something went wrong parsing a serialized principal!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
aSavedResponseOut->mValue.principalInfo() =
|
||||
mozilla::ipc::ContentPrincipalInfo(attrs, originNoSuffix);
|
||||
mozilla::ipc::ContentPrincipalInfo(attrs, void_t(), specNoSuffix);
|
||||
}
|
||||
|
||||
rv = state->GetBlobAsUTF8String(6, aSavedResponseOut->mValue.channelInfo().securityInfo());
|
||||
|
|
|
@ -354,7 +354,7 @@ ServiceWorkerRegistrar::ReadData()
|
|||
GET_LINE(entry->scope());
|
||||
|
||||
entry->principal() =
|
||||
mozilla::ipc::ContentPrincipalInfo(attrs, entry->scope());
|
||||
mozilla::ipc::ContentPrincipalInfo(attrs, void_t(), entry->scope());
|
||||
|
||||
GET_LINE(entry->currentWorkerURL());
|
||||
|
||||
|
@ -395,7 +395,7 @@ ServiceWorkerRegistrar::ReadData()
|
|||
GET_LINE(entry->scope());
|
||||
|
||||
entry->principal() =
|
||||
mozilla::ipc::ContentPrincipalInfo(attrs, entry->scope());
|
||||
mozilla::ipc::ContentPrincipalInfo(attrs, void_t(), entry->scope());
|
||||
|
||||
GET_LINE(entry->currentWorkerURL());
|
||||
|
||||
|
@ -428,7 +428,7 @@ ServiceWorkerRegistrar::ReadData()
|
|||
GET_LINE(entry->scope());
|
||||
|
||||
entry->principal() =
|
||||
mozilla::ipc::ContentPrincipalInfo(attrs, entry->scope());
|
||||
mozilla::ipc::ContentPrincipalInfo(attrs, void_t(), entry->scope());
|
||||
|
||||
GET_LINE(entry->currentWorkerURL());
|
||||
|
||||
|
@ -458,7 +458,7 @@ ServiceWorkerRegistrar::ReadData()
|
|||
GET_LINE(entry->scope());
|
||||
|
||||
entry->principal() =
|
||||
mozilla::ipc::ContentPrincipalInfo(attrs, entry->scope());
|
||||
mozilla::ipc::ContentPrincipalInfo(attrs, void_t(), entry->scope());
|
||||
|
||||
GET_LINE(entry->currentWorkerURL());
|
||||
|
||||
|
@ -488,7 +488,7 @@ ServiceWorkerRegistrar::ReadData()
|
|||
GET_LINE(entry->scope());
|
||||
|
||||
entry->principal() =
|
||||
mozilla::ipc::ContentPrincipalInfo(attrs, entry->scope());
|
||||
mozilla::ipc::ContentPrincipalInfo(attrs, void_t(), entry->scope());
|
||||
|
||||
// scriptSpec is no more used in latest version.
|
||||
GET_LINE(unused);
|
||||
|
|
|
@ -243,7 +243,8 @@ TEST(ServiceWorkerRegistrar, TestWriteData)
|
|||
nsAutoCString spec;
|
||||
spec.AppendPrintf("spec write %d", i);
|
||||
reg.principal() =
|
||||
mozilla::ipc::ContentPrincipalInfo(mozilla::OriginAttributes(i, i % 2), spec);
|
||||
mozilla::ipc::ContentPrincipalInfo(mozilla::OriginAttributes(i, i % 2),
|
||||
mozilla::void_t(), spec);
|
||||
|
||||
swr->TestRegisterServiceWorker(reg);
|
||||
}
|
||||
|
@ -597,7 +598,8 @@ TEST(ServiceWorkerRegistrar, TestDedupeWrite)
|
|||
nsAutoCString spec;
|
||||
spec.AppendPrintf("spec write dedupe/%d", i);
|
||||
reg.principal() =
|
||||
mozilla::ipc::ContentPrincipalInfo(mozilla::OriginAttributes(0, false), spec);
|
||||
mozilla::ipc::ContentPrincipalInfo(mozilla::OriginAttributes(0, false),
|
||||
mozilla::void_t(), spec);
|
||||
|
||||
swr->TestRegisterServiceWorker(reg);
|
||||
}
|
||||
|
|
|
@ -94,6 +94,18 @@ PrincipalInfoToPrincipal(const PrincipalInfo& aPrincipalInfo,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
// When the principal is serialized, the origin is extract from it. This
|
||||
// can fail, and in case, here we will havea Tvoid_t. If we have a string,
|
||||
// it must match with what the_new_principal.getOrigin returns.
|
||||
if (info.originNoSuffix().type() == ContentPrincipalInfoOriginNoSuffix::TnsCString) {
|
||||
nsAutoCString originNoSuffix;
|
||||
rv = principal->GetOriginNoSuffix(originNoSuffix);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)) ||
|
||||
!info.originNoSuffix().get_nsCString().Equals(originNoSuffix)) {
|
||||
MOZ_CRASH("If the origin was in the contentPrincipalInfo, it must be available when deserialized");
|
||||
}
|
||||
}
|
||||
|
||||
return principal.forget();
|
||||
}
|
||||
|
||||
|
@ -222,8 +234,18 @@ PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
|
|||
return rv;
|
||||
}
|
||||
|
||||
ContentPrincipalInfoOriginNoSuffix infoOriginNoSuffix;
|
||||
|
||||
nsCString originNoSuffix;
|
||||
rv = aPrincipal->GetOriginNoSuffix(originNoSuffix);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
infoOriginNoSuffix = void_t();
|
||||
} else {
|
||||
infoOriginNoSuffix = originNoSuffix;
|
||||
}
|
||||
|
||||
*aPrincipalInfo = ContentPrincipalInfo(aPrincipal->OriginAttributesRef(),
|
||||
spec);
|
||||
infoOriginNoSuffix, spec);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,21 @@ using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
|
|||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
union ContentPrincipalInfoOriginNoSuffix
|
||||
{
|
||||
nsCString;
|
||||
void_t;
|
||||
};
|
||||
|
||||
struct ContentPrincipalInfo
|
||||
{
|
||||
OriginAttributes attrs;
|
||||
|
||||
// nsIPrincipal.originNoSuffix can fail. In case this happens, this value
|
||||
// will be set to void_t. So far, this is used only for dom/media.
|
||||
// It will be removed in bug 1347817.
|
||||
ContentPrincipalInfoOriginNoSuffix originNoSuffix;
|
||||
|
||||
nsCString spec;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче