Backed out changeset 54a1f0cb64d9 (bug 1340163) for crashing e.g. in browser/components/originattributes/test/browser/browser_cacheAPI.js. r=backout
authorSebastian Hengst <archaeopteryx@coole-files.de>
Mon, 20 Mar 2017 15:38:19 +0100
changeset 501543 324a8b9f44f4c1cc71022fa2e9279526374c5bfe
parent 501542 aad74c60564368209d819fa264b7719101faacb4
child 501544 c8059931ccdaaa6850ece5ccc5dc48b23bbb0ffe
child 501651 9ce518ccb46660d1fdb53a7e175bdb1092f70052
push id50021
push userbmo:gl@mozilla.com
push dateMon, 20 Mar 2017 14:51:28 +0000
reviewersbackout
bugs1340163
milestone55.0a1
backs out54a1f0cb64d90a95c869fab97c11822730fbc4e8
Backed out changeset 54a1f0cb64d9 (bug 1340163) for crashing e.g. in browser/components/originattributes/test/browser/browser_cacheAPI.js. r=backout
caps/nsJSPrincipals.cpp
dom/cache/DBSchema.cpp
dom/workers/ServiceWorkerRegistrar.cpp
dom/workers/test/gtest/TestReadWrite.cpp
ipc/glue/BackgroundUtils.cpp
ipc/glue/PBackgroundSharedTypes.ipdlh
--- a/caps/nsJSPrincipals.cpp
+++ b/caps/nsJSPrincipals.cpp
@@ -130,32 +130,26 @@ ReadSuffixAndSpec(JSStructuredCloneReade
                   nsACString& aSpec)
 {
     uint32_t suffixLength, specLength;
     if (!JS_ReadUint32Pair(aReader, &suffixLength, &specLength)) {
         return false;
     }
 
     nsAutoCString suffix;
-    if (!suffix.SetLength(suffixLength, fallible)) {
-        return false;
-    }
-
+    suffix.SetLength(suffixLength);
     if (!JS_ReadBytes(aReader, suffix.BeginWriting(), suffixLength)) {
         return false;
     }
 
     if (!aAttrs.PopulateFromSuffix(suffix)) {
         return false;
     }
 
-    if (!aSpec.SetLength(specLength, fallible)) {
-        return false;
-    }
-
+    aSpec.SetLength(specLength);
     if (!JS_ReadBytes(aReader, aSpec.BeginWriting(), specLength)) {
         return false;
     }
 
     return true;
 }
 
 static bool
@@ -196,17 +190,17 @@ ReadPrincipalInfo(JSStructuredCloneReade
         aInfo = expanded;
     } else if (aTag == SCTAG_DOM_CONTENT_PRINCIPAL) {
         OriginAttributes attrs;
         nsAutoCString spec;
         if (!ReadSuffixAndSpec(aReader, attrs, spec)) {
             return false;
         }
 
-        aInfo = ContentPrincipalInfo(attrs, void_t(), spec);
+        aInfo = ContentPrincipalInfo(attrs, spec);
     } else {
         MOZ_CRASH("unexpected principal structured clone tag");
     }
 
     return true;
 }
 
 /* static */ bool
--- a/dom/cache/DBSchema.cpp
+++ b/dom/cache/DBSchema.cpp
@@ -1970,25 +1970,25 @@ ReadResponse(mozIStorageConnection* aCon
   }
 
   nsAutoCString serializedInfo;
   rv = state->GetUTF8String(5, serializedInfo);
   if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
 
   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());
   if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
 
   rv = aConn->CreateStatement(NS_LITERAL_CSTRING(
     "SELECT "
       "name, "
--- a/dom/workers/ServiceWorkerRegistrar.cpp
+++ b/dom/workers/ServiceWorkerRegistrar.cpp
@@ -349,17 +349,17 @@ ServiceWorkerRegistrar::ReadData()
       OriginAttributes attrs;
       if (!attrs.PopulateFromSuffix(suffix)) {
         return NS_ERROR_INVALID_ARG;
       }
 
       GET_LINE(entry->scope());
 
       entry->principal() =
-        mozilla::ipc::ContentPrincipalInfo(attrs, void_t(), entry->scope());
+        mozilla::ipc::ContentPrincipalInfo(attrs, entry->scope());
 
       GET_LINE(entry->currentWorkerURL());
 
       nsAutoCString fetchFlag;
       GET_LINE(fetchFlag);
       if (!fetchFlag.EqualsLiteral(SERVICEWORKERREGISTRAR_TRUE) &&
           !fetchFlag.EqualsLiteral(SERVICEWORKERREGISTRAR_FALSE)) {
         return NS_ERROR_INVALID_ARG;
@@ -390,17 +390,17 @@ ServiceWorkerRegistrar::ReadData()
       OriginAttributes attrs;
       if (!attrs.PopulateFromSuffix(suffix)) {
         return NS_ERROR_INVALID_ARG;
       }
 
       GET_LINE(entry->scope());
 
       entry->principal() =
-        mozilla::ipc::ContentPrincipalInfo(attrs, void_t(), entry->scope());
+        mozilla::ipc::ContentPrincipalInfo(attrs, entry->scope());
 
       GET_LINE(entry->currentWorkerURL());
 
       nsAutoCString fetchFlag;
       GET_LINE(fetchFlag);
       if (!fetchFlag.EqualsLiteral(SERVICEWORKERREGISTRAR_TRUE) &&
           !fetchFlag.EqualsLiteral(SERVICEWORKERREGISTRAR_FALSE)) {
         return NS_ERROR_INVALID_ARG;
@@ -423,17 +423,17 @@ ServiceWorkerRegistrar::ReadData()
       OriginAttributes attrs;
       if (!attrs.PopulateFromSuffix(suffix)) {
         return NS_ERROR_INVALID_ARG;
       }
 
       GET_LINE(entry->scope());
 
       entry->principal() =
-        mozilla::ipc::ContentPrincipalInfo(attrs, void_t(), entry->scope());
+        mozilla::ipc::ContentPrincipalInfo(attrs, entry->scope());
 
       GET_LINE(entry->currentWorkerURL());
 
       // default handlesFetch flag to Enabled
       entry->currentWorkerHandlesFetch() = true;
 
       nsAutoCString cacheName;
       GET_LINE(cacheName);
@@ -453,17 +453,17 @@ ServiceWorkerRegistrar::ReadData()
       }
 
       // principal spec is no longer used; we use scope directly instead
       GET_LINE(unused);
 
       GET_LINE(entry->scope());
 
       entry->principal() =
-        mozilla::ipc::ContentPrincipalInfo(attrs, void_t(), entry->scope());
+        mozilla::ipc::ContentPrincipalInfo(attrs, entry->scope());
 
       GET_LINE(entry->currentWorkerURL());
 
       // default handlesFetch flag to Enabled
       entry->currentWorkerHandlesFetch() = true;
 
       nsAutoCString cacheName;
       GET_LINE(cacheName);
@@ -483,17 +483,17 @@ ServiceWorkerRegistrar::ReadData()
       }
 
       // principal spec is no longer used; we use scope directly instead
       GET_LINE(unused);
 
       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);
 
       GET_LINE(entry->currentWorkerURL());
 
       // default handlesFetch flag to Enabled
       entry->currentWorkerHandlesFetch() = true;
--- a/dom/workers/test/gtest/TestReadWrite.cpp
+++ b/dom/workers/test/gtest/TestReadWrite.cpp
@@ -238,18 +238,17 @@ TEST(ServiceWorkerRegistrar, TestWriteDa
       reg.currentWorkerHandlesFetch() = true;
       reg.cacheName() =
         NS_ConvertUTF8toUTF16(nsPrintfCString("cacheName write %d", i));
       reg.loadFlags() = nsIRequest::VALIDATE_ALWAYS;
 
       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);
     }
 
     nsresult rv = swr->TestWriteData();
     ASSERT_EQ(NS_OK, rv) << "WriteData() should not fail";
   }
 
@@ -593,18 +592,17 @@ TEST(ServiceWorkerRegistrar, TestDedupeW
       reg.currentWorkerHandlesFetch() = true;
       reg.cacheName() =
         NS_ConvertUTF8toUTF16(nsPrintfCString("cacheName write %d", i));
       reg.loadFlags() = nsIRequest::VALIDATE_ALWAYS;
 
       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);
     }
 
     nsresult rv = swr->TestWriteData();
     ASSERT_EQ(NS_OK, rv) << "WriteData() should not fail";
   }
 
--- a/ipc/glue/BackgroundUtils.cpp
+++ b/ipc/glue/BackgroundUtils.cpp
@@ -89,28 +89,16 @@ PrincipalInfoToPrincipal(const Principal
         attrs = info.attrs();
       }
       principal = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
       rv = principal ? NS_OK : NS_ERROR_FAILURE;
       if (NS_WARN_IF(NS_FAILED(rv))) {
         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();
     }
 
     case PrincipalInfo::TExpandedPrincipalInfo: {
       const ExpandedPrincipalInfo& info = aPrincipalInfo.get_ExpandedPrincipalInfo();
 
       nsTArray<nsCOMPtr<nsIPrincipal>> whitelist;
       nsCOMPtr<nsIPrincipal> wlPrincipal;
@@ -229,28 +217,18 @@ PrincipalToPrincipalInfo(nsIPrincipal* a
   }
 
   nsAutoCString spec;
   rv = uri->GetSpec(spec);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     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;
 }
 
 bool
 IsPincipalInfoPrivate(const PrincipalInfo& aPrincipalInfo)
 {
   if (aPrincipalInfo.type() != ipc::PrincipalInfo::TContentPrincipalInfo) {
     return false;
--- a/ipc/glue/PBackgroundSharedTypes.ipdlh
+++ b/ipc/glue/PBackgroundSharedTypes.ipdlh
@@ -3,31 +3,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
 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;
 };
 
 struct SystemPrincipalInfo
 { };
 
 struct NullPrincipalInfo
 {