Backed out changeset a6267555a244 (bug 1341218) for various test failures, e.g. xpcshell test dom/push/test/xpcshell/test_service_parent.js. r=backout
authorSebastian Hengst <archaeopteryx@coole-files.de>
Wed, 22 Feb 2017 11:21:37 +0100
changeset 373255 3e044c903144988434e9f6322a279e2f2a6ce7ce
parent 373254 f748a9e7e08367311302ccb16833f4a9417469e7
child 373256 f5372cb6c3c74464c17a3d2ba2b38299f97a8f05
child 373300 405ee7f97cfa28b579d863deb84a44db7fe4ef88
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1341218
milestone54.0a1
backs outa6267555a244996e92e6e06e8cd05cb8393bb565
Backed out changeset a6267555a244 (bug 1341218) for various test failures, e.g. xpcshell test dom/push/test/xpcshell/test_service_parent.js. r=backout
caps/nsNullPrincipal.cpp
dom/base/nsContentUtils.cpp
dom/base/nsDocument.cpp
--- a/caps/nsNullPrincipal.cpp
+++ b/caps/nsNullPrincipal.cpp
@@ -161,47 +161,30 @@ nsNullPrincipal::GetBaseDomain(nsACStrin
  */
 NS_IMETHODIMP
 nsNullPrincipal::Read(nsIObjectInputStream* aStream)
 {
   // Note - nsNullPrincipal use NS_GENERIC_FACTORY_CONSTRUCTOR_INIT, which means
   // that the Init() method has already been invoked by the time we deserialize.
   // This is in contrast to nsPrincipal, which uses NS_GENERIC_FACTORY_CONSTRUCTOR,
   // in which case ::Read needs to invoke Init().
-
-  nsCOMPtr<nsISupports> supports;
-  nsresult rv = NS_ReadOptionalObject(aStream, true, getter_AddRefs(supports));
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-
-  nsCOMPtr<nsIURI> uri = do_QueryInterface(supports);
-
   nsAutoCString suffix;
-  rv = aStream->ReadCString(suffix);
+  nsresult rv = aStream->ReadCString(suffix);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  OriginAttributes attrs;
-  bool ok = attrs.PopulateFromSuffix(suffix);
+  bool ok = mOriginAttributes.PopulateFromSuffix(suffix);
   NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
 
-  return Init(attrs, uri);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNullPrincipal::Write(nsIObjectOutputStream* aStream)
 {
-  NS_ENSURE_STATE(mURI);
-  nsresult rv = NS_WriteOptionalCompoundObject(aStream, mURI, NS_GET_IID(nsIURI),
-                                               true);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-
   nsAutoCString suffix;
   OriginAttributesRef().CreateSuffix(suffix);
 
-  rv = aStream->WriteStringZ(suffix.get());
+  nsresult rv = aStream->WriteStringZ(suffix.get());
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -507,21 +507,20 @@ nsContentUtils::Init()
   sSecurityManager = nsScriptSecurityManager::GetScriptSecurityManager();
   if(!sSecurityManager)
     return NS_ERROR_FAILURE;
   NS_ADDREF(sSecurityManager);
 
   sSecurityManager->GetSystemPrincipal(&sSystemPrincipal);
   MOZ_ASSERT(sSystemPrincipal);
 
-  RefPtr<nsNullPrincipal> nullPrincipal = nsNullPrincipal::Create();
-  if (!nullPrincipal) {
-    return NS_ERROR_FAILURE;
-  }
-
+  // We use the constructor here because we want infallible initialization; we
+  // apparently don't care whether sNullSubjectPrincipal has a sane URI or not.
+  RefPtr<nsNullPrincipal> nullPrincipal = new nsNullPrincipal();
+  nullPrincipal->Init();
   nullPrincipal.forget(&sNullSubjectPrincipal);
 
   nsresult rv = CallGetService(NS_IOSERVICE_CONTRACTID, &sIOService);
   if (NS_FAILED(rv)) {
     // This makes life easier, but we can live without it.
 
     sIOService = nullptr;
   }
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -99,17 +99,16 @@
 #include "nsNetUtil.h"     // for NS_NewURI
 #include "nsIInputStreamChannel.h"
 #include "nsIAuthPrompt.h"
 #include "nsIAuthPrompt2.h"
 
 #include "nsIScriptSecurityManager.h"
 #include "nsIPermissionManager.h"
 #include "nsIPrincipal.h"
-#include "nsNullPrincipal.h"
 
 #include "nsIDOMWindow.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMElement.h"
 #include "nsFocusManager.h"
 
 // for radio group stuff
 #include "nsIDOMHTMLInputElement.h"
@@ -2735,17 +2734,17 @@ nsDocument::InitCSP(nsIChannel* aChannel
   rv = csp->GetCSPSandboxFlags(&cspSandboxFlags);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mSandboxFlags |= cspSandboxFlags;
 
   if (cspSandboxFlags & SANDBOXED_ORIGIN) {
     // If the new CSP sandbox flags do not have the allow-same-origin flag
     // reset the document principal to a null principal
-    principal = nsNullPrincipal::Create();
+    principal = do_CreateInstance("@mozilla.org/nullprincipal;1");
     SetPrincipal(principal);
   }
 
   // ----- Enforce frame-ancestor policy on any applied policies
   nsCOMPtr<nsIDocShell> docShell(mDocumentContainer);
   if (docShell) {
     bool safeAncestry = false;