Backed out changeset 33c7b0ea5caa (bug 1485177) for assertion failure at builds/worker/workspace/build/src/caps/ContentPrincipal.cpp on a CLOSED TREE
authorTiberius Oros <toros@mozilla.com>
Sat, 01 Sep 2018 05:06:55 +0300
changeset 489513 30c890dba6ea44e4dbea9ef8bf82a67eac67eee2
parent 489512 6fc9e0fc33de5fb8a1b6450a3b28515296f66f36
child 489514 5ebac82b70a5d219a4106197a3b95b7bef8caee1
push id9738
push useraciure@mozilla.com
push dateMon, 03 Sep 2018 16:13:51 +0000
treeherdermozilla-beta@f5841408a66c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1485177
milestone63.0a1
backs out33c7b0ea5caaa654c72cce43124db1ebc052dead
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 33c7b0ea5caa (bug 1485177) for assertion failure at builds/worker/workspace/build/src/caps/ContentPrincipal.cpp on a CLOSED TREE
caps/BasePrincipal.cpp
caps/BasePrincipal.h
caps/ContentPrincipal.cpp
caps/ContentPrincipal.h
caps/nsIPrincipal.idl
--- a/caps/BasePrincipal.cpp
+++ b/caps/BasePrincipal.cpp
@@ -54,23 +54,16 @@ BasePrincipal::GetOrigin(nsACString& aOr
 NS_IMETHODIMP
 BasePrincipal::GetOriginNoSuffix(nsACString& aOrigin)
 {
   MOZ_ASSERT(mInitialized);
   mOriginNoSuffix->ToUTF8String(aOrigin);
   return NS_OK;
 }
 
-NS_IMETHODIMP
-BasePrincipal::GetSiteOrigin(nsACString& aSiteOrigin)
-{
-  MOZ_ASSERT(mInitialized);
-  return GetOrigin(aSiteOrigin);
-}
-
 bool
 BasePrincipal::Subsumes(nsIPrincipal* aOther, DocumentDomainConsideration aConsideration)
 {
   MOZ_ASSERT(aOther);
   MOZ_ASSERT_IF(Kind() == eCodebasePrincipal, mOriginSuffix);
 
   // Expanded principals handle origin attributes for each of their
   // sub-principals individually, null principals do only simple checks for
--- a/caps/BasePrincipal.h
+++ b/caps/BasePrincipal.h
@@ -81,17 +81,16 @@ public:
   NS_IMETHOD GetIsSystemPrincipal(bool* aResult) override;
   NS_IMETHOD GetIsAddonOrExpandedAddonPrincipal(bool* aResult) override;
   NS_IMETHOD GetOriginAttributes(JSContext* aCx, JS::MutableHandle<JS::Value> aVal) final;
   NS_IMETHOD GetOriginSuffix(nsACString& aOriginSuffix) final;
   NS_IMETHOD GetAppId(uint32_t* aAppId) final;
   NS_IMETHOD GetIsInIsolatedMozBrowserElement(bool* aIsInIsolatedMozBrowserElement) final;
   NS_IMETHOD GetUserContextId(uint32_t* aUserContextId) final;
   NS_IMETHOD GetPrivateBrowsingId(uint32_t* aPrivateBrowsingId) final;
-  NS_IMETHOD GetSiteOrigin(nsACString& aOrigin) override;
 
   virtual bool AddonHasPermission(const nsAtom* aPerm);
 
   virtual bool IsCodebasePrincipal() const { return false; };
 
   static BasePrincipal* Cast(nsIPrincipal* aPrin) { return static_cast<BasePrincipal*>(aPrin); }
 
   static already_AddRefed<BasePrincipal>
--- a/caps/ContentPrincipal.cpp
+++ b/caps/ContentPrincipal.cpp
@@ -12,17 +12,16 @@
 #include "nsScriptSecurityManager.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "pratom.h"
 #include "nsIURI.h"
 #include "nsIURL.h"
 #include "nsIStandardURL.h"
 #include "nsIURIWithSpecialOrigin.h"
-#include "nsIURIMutator.h"
 #include "nsJSPrincipals.h"
 #include "nsIEffectiveTLDService.h"
 #include "nsIClassInfoImpl.h"
 #include "nsIObjectInputStream.h"
 #include "nsIObjectOutputStream.h"
 #include "nsIProtocolHandler.h"
 #include "nsError.h"
 #include "nsIContentSecurityPolicy.h"
@@ -243,28 +242,17 @@ ContentPrincipal::SubsumesInternal(nsIPr
     // Get .domain on each principal.
     nsCOMPtr<nsIURI> thisDomain, otherDomain;
     GetDomain(getter_AddRefs(thisDomain));
     aOther->GetDomain(getter_AddRefs(otherDomain));
 
     // If either has .domain set, we have equality i.f.f. the domains match.
     // Otherwise, we fall through to the non-document-domain-considering case.
     if (thisDomain || otherDomain) {
-      bool isMatch =
-        nsScriptSecurityManager::SecurityCompareURIs(thisDomain, otherDomain);
-#ifdef DEBUG
-      if (isMatch) {
-        nsAutoCString thisSiteOrigin, otherSiteOrigin;
-        MOZ_ALWAYS_SUCCEEDS(GetSiteOrigin(thisSiteOrigin));
-        MOZ_ALWAYS_SUCCEEDS(aOther->GetSiteOrigin(otherSiteOrigin));
-        MOZ_ASSERT(thisSiteOrigin == otherSiteOrigin,
-          "SubsumesConsideringDomain passed with mismatched siteOrigin!");
-      }
-#endif
-      return isMatch;
+      return nsScriptSecurityManager::SecurityCompareURIs(thisDomain, otherDomain);
     }
   }
 
   nsCOMPtr<nsIURI> otherURI;
   rv = aOther->GetURI(getter_AddRefs(otherURI));
   NS_ENSURE_SUCCESS(rv, false);
 
   // Compare codebases.
@@ -398,60 +386,16 @@ ContentPrincipal::GetBaseDomain(nsACStri
     do_GetService(THIRDPARTYUTIL_CONTRACTID);
   if (thirdPartyUtil) {
     return thirdPartyUtil->GetBaseDomain(mCodebase, aBaseDomain);
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP
-ContentPrincipal::GetSiteOrigin(nsACString& aSiteOrigin)
-{
-  // Get the eTLDService & determine our base domain. If we don't have a valid
-  // BaseDomain, we can fall-back to GetOrigin.
-  nsCOMPtr<nsIEffectiveTLDService> tldService =
-    do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID);
-  if (NS_WARN_IF(!tldService)) {
-    return GetOrigin(aSiteOrigin);
-  }
-
-  nsAutoCString baseDomain;
-  nsresult rv = tldService->GetBaseDomain(mCodebase, 0, baseDomain);
-  if (NS_FAILED(rv)) {
-    return GetOrigin(aSiteOrigin);
-  }
-
-  nsCOMPtr<nsIURI> siteUri;
-  rv = NS_MutateURI(mCodebase)
-    .SetUserPass(EmptyCString())
-    .SetHostPort(baseDomain)
-    .Finalize(siteUri);
-  MOZ_ASSERT(NS_SUCCEEDED(rv), "failed to create siteUri");
-  if (NS_FAILED(rv)) {
-    return GetOrigin(aSiteOrigin);
-  }
-
-  rv = GenerateOriginNoSuffixFromURI(siteUri, aSiteOrigin);
-  MOZ_ASSERT(NS_SUCCEEDED(rv), "failed to create siteOriginNoSuffix");
-  if (NS_FAILED(rv)) {
-    return GetOrigin(aSiteOrigin);
-  }
-
-  nsAutoCString suffix;
-  rv = GetOriginSuffix(suffix);
-  MOZ_ASSERT(NS_SUCCEEDED(rv), "failed to create suffix");
-  if (NS_FAILED(rv)) {
-    return GetOrigin(aSiteOrigin);
-  }
-
-  aSiteOrigin.Append(suffix);
-  return NS_OK;
-}
-
 WebExtensionPolicy*
 ContentPrincipal::AddonPolicy()
 {
   if (!mAddon.isSome()) {
     NS_ENSURE_TRUE(mCodebase, nullptr);
 
     bool isMozExt;
     if (NS_SUCCEEDED(mCodebase->SchemeIs("moz-extension", &isMozExt)) && isMozExt) {
--- a/caps/ContentPrincipal.h
+++ b/caps/ContentPrincipal.h
@@ -24,17 +24,16 @@ public:
   NS_DECL_NSISERIALIZABLE
   NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
   NS_IMETHOD GetHashValue(uint32_t* aHashValue) override;
   NS_IMETHOD GetURI(nsIURI** aURI) override;
   NS_IMETHOD GetDomain(nsIURI** aDomain) override;
   NS_IMETHOD SetDomain(nsIURI* aDomain) override;
   NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override;
   NS_IMETHOD GetAddonId(nsAString& aAddonId) override;
-  NS_IMETHOD GetSiteOrigin(nsACString& aSiteOrigin) override;
   bool IsCodebasePrincipal() const override { return true; }
 
   ContentPrincipal();
 
   static PrincipalKind Kind() { return eCodebasePrincipal; }
 
   // Init() must be called before the principal is in a usable state.
   nsresult Init(nsIURI* aCodebase,
--- a/caps/nsIPrincipal.idl
+++ b/caps/nsIPrincipal.idl
@@ -241,30 +241,16 @@ interface nsIPrincipal : nsISerializable
      *
      * The value of .originSuffix is automatically serialized into .origin, so any
      * consumers using that are automatically origin-attribute-aware. Consumers with
      * special requirements must inspect and compare .originSuffix manually.
      */
     readonly attribute AUTF8String originSuffix;
 
     /**
-     * A canonical representation of the site-origin for this principal.
-     * This string has the same format as |origin| (see above). Two principals
-     * with differing |siteOrigin| values will never compare equal, even when
-     * considering domain mutations.
-     *
-     * For most principals, |siteOrigin| matches |origin| precisely. Only
-     * principals which allow mutating |domain|, such as ContentPrincipal,
-     * override the default implementation in BasePrincipal.
-     *
-     * TODO(nika): Use this in DocGroup.
-     */
-    readonly attribute ACString siteOrigin;
-
-    /**
      * The base domain of the codebase URI to which this principal pertains
      * (generally the document URI), handling null principals and
      * non-hierarchical schemes correctly.
      */
     readonly attribute ACString baseDomain;
 
     /**
      * Gets the id of the app this principal is inside.  If this principal is