Bug 1497995 - Remove URI null checks in nsDocShell::InternalLoad; r=bzbarsky
authorKyle Machulis <kyle@nonpolynomial.com>
Wed, 19 Dec 2018 21:02:20 +0000
changeset 451759 70996d85e8beb2a4053f0938da90b55354e2ef5a
parent 451758 63e0af38669e2984ebd98f83499ab7aea383ff92
child 451760 492d66a0a98a1fed4b30ceecd8e0d2ae54dbe7be
push id35253
push userccoroiu@mozilla.com
push dateSat, 22 Dec 2018 04:12:04 +0000
treeherdermozilla-central@d30b4fd63e17 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs1497995
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 1497995 - Remove URI null checks in nsDocShell::InternalLoad; r=bzbarsky We can't have null URIs now, so remove checks. Depends on D13490 Differential Revision: https://phabricator.services.mozilla.com/D13491
docshell/base/nsDocShell.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -657,17 +657,16 @@ nsDocShell::GetInterface(const nsIID& aI
 }
 
 NS_IMETHODIMP
 nsDocShell::LoadURI(nsDocShellLoadState* aLoadState) {
   MOZ_ASSERT(aLoadState, "Must have a valid load state!");
   MOZ_ASSERT(
       (aLoadState->LoadFlags() & INTERNAL_LOAD_FLAGS_LOADURI_SETUP_FLAGS) == 0,
       "Should not have these flags set");
-  MOZ_ASSERT(aLoadState->URI(), "Should have a valid URI to load");
 
   if (!aLoadState->TriggeringPrincipal()) {
 #ifndef ANDROID
     MOZ_ASSERT(false, "LoadURI must have a triggering principal");
 #endif
     if (mUseStrictSecurityChecks) {
       return NS_ERROR_FAILURE;
     }
@@ -8646,30 +8645,26 @@ nsresult nsDocShell::InternalLoad(nsDocS
   }
 
   nsresult rv = NS_OK;
   mOriginalUriString.Truncate();
 
   MOZ_LOG(
       gDocShellLeakLog, LogLevel::Debug,
       ("DOCSHELL %p InternalLoad %s\n", this,
-       aLoadState->URI() ? aLoadState->URI()->GetSpecOrDefault().get() : ""));
+      aLoadState->URI()->GetSpecOrDefault().get()));
 
   // Initialize aDocShell/aRequest
   if (aDocShell) {
     *aDocShell = nullptr;
   }
   if (aRequest) {
     *aRequest = nullptr;
   }
 
-  if (!aLoadState->URI()) {
-    return NS_ERROR_NULL_POINTER;
-  }
-
   NS_ENSURE_TRUE(IsValidLoadType(aLoadState->LoadType()), NS_ERROR_INVALID_ARG);
 
   NS_ENSURE_TRUE(!mIsBeingDestroyed, NS_ERROR_NOT_AVAILABLE);
 
   rv = EnsureScriptEnvironment();
   if (NS_FAILED(rv)) {
     return rv;
   }
@@ -8810,18 +8805,17 @@ nsresult nsDocShell::InternalLoad(nsDocS
     }
   }
 
   nsIDocument* doc = mContentViewer ? mContentViewer->GetDocument() : nullptr;
 
   const bool isDocumentAuxSandboxed =
       doc && (doc->GetSandboxFlags() & SANDBOXED_AUXILIARY_NAVIGATION);
 
-  if (aLoadState->URI() && mLoadURIDelegate &&
-      aLoadState->LoadType() != LOAD_ERROR_PAGE &&
+  if (mLoadURIDelegate && aLoadState->LoadType() != LOAD_ERROR_PAGE &&
       (!targetDocShell || targetDocShell == static_cast<nsIDocShell*>(this))) {
     // Dispatch only load requests for the current or a new window to the
     // delegate, e.g., to allow for GeckoView apps to handle the load event
     // outside of Gecko.
     const int where = (aLoadState->Target().IsEmpty() || targetDocShell)
                           ? nsIBrowserDOMWindow::OPEN_CURRENTWINDOW
                           : nsIBrowserDOMWindow::OPEN_NEWWINDOW;
 
@@ -8861,19 +8855,18 @@ nsresult nsDocShell::InternalLoad(nsDocS
         return NS_ERROR_DOM_INVALID_ACCESS_ERR;
       }
 
       nsCOMPtr<nsPIDOMWindowOuter> win = GetWindow();
       NS_ENSURE_TRUE(win, NS_ERROR_NOT_AVAILABLE);
 
       nsCOMPtr<nsPIDOMWindowOuter> newWin;
       nsAutoCString spec;
-      if (aLoadState->URI()) {
-        aLoadState->URI()->GetSpec(spec);
-      }
+      aLoadState->URI()->GetSpec(spec);
+
       // If we are a noopener load, we just hand the whole thing over to our
       // window.
       if (aLoadState->HasLoadFlags(INTERNAL_LOAD_FLAGS_NO_OPENER)) {
         // Various asserts that we know to hold because NO_OPENER loads can only
         // happen for links.
         MOZ_ASSERT(!aLoadState->LoadReplace());
         MOZ_ASSERT(aLoadState->PrincipalToInherit() ==
                    aLoadState->TriggeringPrincipal());