From a472d9b04f2443bd1f1702a1441253e33606d1a5 Mon Sep 17 00:00:00 2001 From: Sebastian Hengst Date: Mon, 20 Mar 2017 15:38:19 +0100 Subject: [PATCH] Backed out changeset 54a1f0cb64d9 (bug 1340163) for crashing e.g. in browser/components/originattributes/test/browser/browser_cacheAPI.js. r=backout --- caps/nsJSPrincipals.cpp | 12 +++--------- dom/cache/DBSchema.cpp | 6 +++--- dom/workers/ServiceWorkerRegistrar.cpp | 10 +++++----- dom/workers/test/gtest/TestReadWrite.cpp | 6 ++---- ipc/glue/BackgroundUtils.cpp | 24 +----------------------- ipc/glue/PBackgroundSharedTypes.ipdlh | 12 ------------ 6 files changed, 14 insertions(+), 56 deletions(-) diff --git a/caps/nsJSPrincipals.cpp b/caps/nsJSPrincipals.cpp index 6a69d5b12b60..ca998bc99597 100644 --- a/caps/nsJSPrincipals.cpp +++ b/caps/nsJSPrincipals.cpp @@ -135,10 +135,7 @@ ReadSuffixAndSpec(JSStructuredCloneReader* aReader, } nsAutoCString suffix; - if (!suffix.SetLength(suffixLength, fallible)) { - return false; - } - + suffix.SetLength(suffixLength); if (!JS_ReadBytes(aReader, suffix.BeginWriting(), suffixLength)) { return false; } @@ -147,10 +144,7 @@ ReadSuffixAndSpec(JSStructuredCloneReader* aReader, return false; } - if (!aSpec.SetLength(specLength, fallible)) { - return false; - } - + aSpec.SetLength(specLength); if (!JS_ReadBytes(aReader, aSpec.BeginWriting(), specLength)) { return false; } @@ -201,7 +195,7 @@ ReadPrincipalInfo(JSStructuredCloneReader* aReader, return false; } - aInfo = ContentPrincipalInfo(attrs, void_t(), spec); + aInfo = ContentPrincipalInfo(attrs, spec); } else { MOZ_CRASH("unexpected principal structured clone tag"); } diff --git a/dom/cache/DBSchema.cpp b/dom/cache/DBSchema.cpp index 8a5d5df0b35a..8b24dd13eb19 100644 --- a/dom/cache/DBSchema.cpp +++ b/dom/cache/DBSchema.cpp @@ -1975,15 +1975,15 @@ ReadResponse(mozIStorageConnection* aConn, EntryId aEntryId, aSavedResponseOut->mValue.principalInfo() = void_t(); if (!serializedInfo.IsEmpty()) { - nsAutoCString specNoSuffix; + nsAutoCString originNoSuffix; OriginAttributes attrs; - if (!attrs.PopulateFromOrigin(serializedInfo, specNoSuffix)) { + if (!attrs.PopulateFromOrigin(serializedInfo, originNoSuffix)) { NS_WARNING("Something went wrong parsing a serialized principal!"); return NS_ERROR_FAILURE; } aSavedResponseOut->mValue.principalInfo() = - mozilla::ipc::ContentPrincipalInfo(attrs, void_t(), specNoSuffix); + mozilla::ipc::ContentPrincipalInfo(attrs, originNoSuffix); } rv = state->GetBlobAsUTF8String(6, aSavedResponseOut->mValue.channelInfo().securityInfo()); diff --git a/dom/workers/ServiceWorkerRegistrar.cpp b/dom/workers/ServiceWorkerRegistrar.cpp index c1fce972814d..fd44329de034 100644 --- a/dom/workers/ServiceWorkerRegistrar.cpp +++ b/dom/workers/ServiceWorkerRegistrar.cpp @@ -354,7 +354,7 @@ ServiceWorkerRegistrar::ReadData() GET_LINE(entry->scope()); entry->principal() = - mozilla::ipc::ContentPrincipalInfo(attrs, void_t(), entry->scope()); + mozilla::ipc::ContentPrincipalInfo(attrs, entry->scope()); GET_LINE(entry->currentWorkerURL()); @@ -395,7 +395,7 @@ ServiceWorkerRegistrar::ReadData() GET_LINE(entry->scope()); entry->principal() = - mozilla::ipc::ContentPrincipalInfo(attrs, void_t(), entry->scope()); + mozilla::ipc::ContentPrincipalInfo(attrs, entry->scope()); GET_LINE(entry->currentWorkerURL()); @@ -428,7 +428,7 @@ ServiceWorkerRegistrar::ReadData() GET_LINE(entry->scope()); entry->principal() = - mozilla::ipc::ContentPrincipalInfo(attrs, void_t(), entry->scope()); + mozilla::ipc::ContentPrincipalInfo(attrs, entry->scope()); GET_LINE(entry->currentWorkerURL()); @@ -458,7 +458,7 @@ ServiceWorkerRegistrar::ReadData() GET_LINE(entry->scope()); entry->principal() = - mozilla::ipc::ContentPrincipalInfo(attrs, void_t(), entry->scope()); + mozilla::ipc::ContentPrincipalInfo(attrs, entry->scope()); GET_LINE(entry->currentWorkerURL()); @@ -488,7 +488,7 @@ ServiceWorkerRegistrar::ReadData() GET_LINE(entry->scope()); entry->principal() = - mozilla::ipc::ContentPrincipalInfo(attrs, void_t(), entry->scope()); + mozilla::ipc::ContentPrincipalInfo(attrs, entry->scope()); // scriptSpec is no more used in latest version. GET_LINE(unused); diff --git a/dom/workers/test/gtest/TestReadWrite.cpp b/dom/workers/test/gtest/TestReadWrite.cpp index 39baa63bda24..e53a72af72a7 100644 --- a/dom/workers/test/gtest/TestReadWrite.cpp +++ b/dom/workers/test/gtest/TestReadWrite.cpp @@ -243,8 +243,7 @@ TEST(ServiceWorkerRegistrar, TestWriteData) nsAutoCString spec; spec.AppendPrintf("spec write %d", i); reg.principal() = - mozilla::ipc::ContentPrincipalInfo(mozilla::OriginAttributes(i, i % 2), - mozilla::void_t(), spec); + mozilla::ipc::ContentPrincipalInfo(mozilla::OriginAttributes(i, i % 2), spec); swr->TestRegisterServiceWorker(reg); } @@ -598,8 +597,7 @@ TEST(ServiceWorkerRegistrar, TestDedupeWrite) nsAutoCString spec; spec.AppendPrintf("spec write dedupe/%d", i); reg.principal() = - mozilla::ipc::ContentPrincipalInfo(mozilla::OriginAttributes(0, false), - mozilla::void_t(), spec); + mozilla::ipc::ContentPrincipalInfo(mozilla::OriginAttributes(0, false), spec); swr->TestRegisterServiceWorker(reg); } diff --git a/ipc/glue/BackgroundUtils.cpp b/ipc/glue/BackgroundUtils.cpp index 4540ee6b9fa2..341b9ecba22a 100644 --- a/ipc/glue/BackgroundUtils.cpp +++ b/ipc/glue/BackgroundUtils.cpp @@ -94,18 +94,6 @@ 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->GetOrigin(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(); } @@ -234,18 +222,8 @@ 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(), - infoOriginNoSuffix, spec); + spec); return NS_OK; } diff --git a/ipc/glue/PBackgroundSharedTypes.ipdlh b/ipc/glue/PBackgroundSharedTypes.ipdlh index 2e5e835a3139..d29737f07bdc 100644 --- a/ipc/glue/PBackgroundSharedTypes.ipdlh +++ b/ipc/glue/PBackgroundSharedTypes.ipdlh @@ -8,21 +8,9 @@ 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; };