Bug 1518986 - Change docshell/ to use infallible Principal URL accessor; r=bzbarsky
authorKyle Machulis <kyle@nonpolynomial.com>
Mon, 14 Jan 2019 22:40:33 +0000
changeset 454306 10b6c352897a7bc2607abd5f66e96730cf74afcd
parent 454305 98d21b0ac30eb2dd19b0dfeae12553e36ff9bc51
child 454307 c63fdb43c80ceed8e580b5760a2e632844c30f5e
push id35392
push userncsoregi@mozilla.com
push dateThu, 17 Jan 2019 21:53:28 +0000
treeherdermozilla-central@24982570fc83 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs1518986
milestone66.0a1
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
Bug 1518986 - Change docshell/ to use infallible Principal URL accessor; r=bzbarsky Depends on D16372 Differential Revision: https://phabricator.services.mozilla.com/D16373
docshell/base/nsDocShell.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -5502,19 +5502,18 @@ nsDocShell::GetAllowMixedContentAndConne
 
   // now get the document from sameTypeRoot
   RefPtr<Document> rootDoc = sameTypeRoot->GetDocument();
   if (rootDoc) {
     nsCOMPtr<nsIPrincipal> rootPrincipal = rootDoc->NodePrincipal();
 
     // For things with system principal (e.g. scratchpad) there is no uri
     // aRootHasSecureConnection should be false.
-    nsCOMPtr<nsIURI> rootUri;
+    nsCOMPtr<nsIURI> rootUri = rootPrincipal->GetURI();
     if (nsContentUtils::IsSystemPrincipal(rootPrincipal) ||
-        NS_FAILED(rootPrincipal->GetURI(getter_AddRefs(rootUri))) ||
         !rootUri || !SchemeIsHTTPS(rootUri)) {
       *aRootHasSecureConnection = false;
     }
 
     // Check the root doc's channel against the root docShell's
     // mMixedContentChannel to see if they are the same. If they are the same,
     // the user has overriden the block.
     nsCOMPtr<nsIDocShell> rootDocShell = do_QueryInterface(sameTypeRoot);
@@ -9585,26 +9584,25 @@ static bool IsConsideredSameOriginForUIR
   if (aTriggeringPrincipal->Equals(aResultPrincipal)) {
     return true;
   }
 
   if (!aResultPrincipal->GetIsCodebasePrincipal()) {
     return false;
   }
 
-  nsCOMPtr<nsIURI> resultURI;
-  nsresult rv = aResultPrincipal->GetURI(getter_AddRefs(resultURI));
-  NS_ENSURE_SUCCESS(rv, false);
+  nsCOMPtr<nsIURI> resultURI = aResultPrincipal->GetURI();
 
   // We know this is a codebase principal, and codebase principals require valid
   // URIs, so we shouldn't need to check non-null here.
   if (!SchemeIsHTTP(resultURI)) {
     return false;
   }
 
+  nsresult rv;
   nsAutoCString tmpResultSpec;
   rv = resultURI->GetSpec(tmpResultSpec);
   NS_ENSURE_SUCCESS(rv, false);
   // replace http with https
   tmpResultSpec.ReplaceLiteral(0, 4, "https");
 
   nsCOMPtr<nsIURI> tmpResultURI;
   rv = NS_NewURI(getter_AddRefs(tmpResultURI), tmpResultSpec);