Backed out changeset 47e14ba39a78 (bug 1600051) for causing crashes in ReferrerInfo.cpp
authorMihai Alexandru Michis <malexandru@mozilla.com>
Wed, 25 Mar 2020 14:39:18 +0200
changeset 520351 592a05a2a15958b9b2628a95e13f8e0731721024
parent 520350 c85b4839c96465336e60adca42734970b14289ad
child 520352 34504844db0385989cf04808bb2657ae3fc4eaba
push id37248
push userbtara@mozilla.com
push dateWed, 25 Mar 2020 16:40:49 +0000
treeherdermozilla-central@c5112a7573ac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1600051
milestone76.0a1
backs out47e14ba39a7841f064056c543896f2dbf5853b24
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 47e14ba39a78 (bug 1600051) for causing crashes in ReferrerInfo.cpp CLOSED TREE
dom/security/ReferrerInfo.cpp
--- a/dom/security/ReferrerInfo.cpp
+++ b/dom/security/ReferrerInfo.cpp
@@ -1013,19 +1013,21 @@ already_AddRefed<nsIReferrerInfo> Referr
   MOZ_ASSERT(aPrincipal);
 
   nsCOMPtr<nsIReferrerInfo> referrerInfo;
   if (!aPrincipal || aPrincipal->IsSystemPrincipal()) {
     referrerInfo = new ReferrerInfo(nullptr);
     return referrerInfo.forget();
   }
 
+  nsCOMPtr<nsIURI> principalURI;
+  aPrincipal->GetURI(getter_AddRefs(principalURI));
+
   if (!aDoc) {
-    aPrincipal->CreateReferrerInfo(ReferrerPolicy::_empty,
-                                   getter_AddRefs(referrerInfo));
+    referrerInfo = new ReferrerInfo(principalURI, ReferrerPolicy::_empty);
     return referrerInfo.forget();
   }
 
   // If it weren't for history.push/replaceState, we could just use the
   // principal's URI here.  But since we want changes to the URI effected
   // by push/replaceState to be reflected in the XHR referrer, we have to
   // be more clever.
   //
@@ -1033,26 +1035,29 @@ already_AddRefed<nsIReferrerInfo> Referr
   // our principal, then we use the document's current URI (after
   // push/replaceStates).  Otherwise (if the document is, say, a data:
   // URI), we just use the principal's URI.
   nsCOMPtr<nsIURI> docCurURI = aDoc->GetDocumentURI();
   nsCOMPtr<nsIURI> docOrigURI = aDoc->GetOriginalURI();
 
   nsCOMPtr<nsIURI> referrerURI;
 
-  if (docCurURI && docOrigURI) {
+  if (principalURI && docCurURI && docOrigURI) {
     bool equal = false;
-    aPrincipal->EqualsURI(docOrigURI, &equal);
+    principalURI->Equals(docOrigURI, &equal);
     if (equal) {
-      referrerInfo = new ReferrerInfo(docCurURI, aDoc->GetReferrerPolicy());
-      return referrerInfo.forget();
+      referrerURI = docCurURI;
     }
   }
-  aPrincipal->CreateReferrerInfo(aDoc->GetReferrerPolicy(),
-                                 getter_AddRefs(referrerInfo));
+
+  if (!referrerURI) {
+    referrerURI = principalURI;
+  }
+
+  referrerInfo = new ReferrerInfo(referrerURI, aDoc->GetReferrerPolicy());
   return referrerInfo.forget();
 }
 
 /* static */
 already_AddRefed<nsIReferrerInfo> ReferrerInfo::CreateForExternalCSSResources(
     mozilla::StyleSheet* aExternalSheet, ReferrerPolicyEnum aPolicy) {
   MOZ_ASSERT(aExternalSheet && !aExternalSheet->IsInline());
   nsCOMPtr<nsIReferrerInfo> referrerInfo;