Bug 1487328 - Clarify which nsIWebNavigation methods in nsSHistory are unreachable. r=nika
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 03 Sep 2018 09:27:37 +1000
changeset 492211 b1eb8b58455a174f42f2eb10b7a1e4c9d0c469ca
parent 492210 983079ec9a0d669b16e9fd03b58c4f9465ebc02c
child 492212 4007042881de2880375d1630f320050ef66eae61
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika
bugs1487328
milestone63.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 1487328 - Clarify which nsIWebNavigation methods in nsSHistory are unreachable. r=nika The only ones that are reachable are GotoIndex(), GetCurrentURI(), and Reload(). This patch makes all the others crash. Note that the reason that Go{Back,Forward}() are unreachable is because of this behaviour in ChildHistory::Go(): // XXX(nika): Should we turn Go(-1) and Go(1) to call GoForward and GoBack? // They technically fire different change events but I couldn't find anyone // who cares, so I'm inclined not to. I.e. those functions are now subsumed by GotoIndex(). As for CanGo{Back,Forward}(), a try push plus code inspection confirm that they are unused.
docshell/shistory/nsSHistory.cpp
--- a/docshell/shistory/nsSHistory.cpp
+++ b/docshell/shistory/nsSHistory.cpp
@@ -960,70 +960,35 @@ nsSHistory::EvictAllContentViewers()
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHistory::GetCanGoBack(bool* aCanGoBack)
 {
-  NS_ENSURE_ARG_POINTER(aCanGoBack);
-
-  int32_t index = -1;
-  NS_ENSURE_SUCCESS(GetIndex(&index), NS_ERROR_FAILURE);
-  if (index > 0) {
-    *aCanGoBack = true;
-    return NS_OK;
-  }
-
-  *aCanGoBack = false;
-  return NS_OK;
+  MOZ_CRASH("nsSHistory::GetCanGoBack");
 }
 
 NS_IMETHODIMP
 nsSHistory::GetCanGoForward(bool* aCanGoForward)
 {
-  NS_ENSURE_ARG_POINTER(aCanGoForward);
-
-  int32_t index = -1;
-  int32_t count = -1;
-  NS_ENSURE_SUCCESS(GetIndex(&index), NS_ERROR_FAILURE);
-  NS_ENSURE_SUCCESS(GetCount(&count), NS_ERROR_FAILURE);
-  if (index >= 0 && index < (count - 1)) {
-    *aCanGoForward = true;
-    return NS_OK;
-  }
-
-  *aCanGoForward = false;
-  return NS_OK;
+  MOZ_CRASH("nsSHistory::GetCanGoForward");
 }
 
 NS_IMETHODIMP
 nsSHistory::GoBack()
 {
-  bool canGoBack = false;
-
-  GetCanGoBack(&canGoBack);
-  if (!canGoBack) {
-    return NS_ERROR_UNEXPECTED;
-  }
-  return LoadEntry(mIndex - 1, LOAD_HISTORY, HIST_CMD_BACK);
+  MOZ_CRASH("nsSHistory::GoBack");
 }
 
 NS_IMETHODIMP
 nsSHistory::GoForward()
 {
-  bool canGoForward = false;
-
-  GetCanGoForward(&canGoForward);
-  if (!canGoForward) {
-    return NS_ERROR_UNEXPECTED;
-  }
-  return LoadEntry(mIndex + 1, LOAD_HISTORY,
-                   HIST_CMD_FORWARD);
+  MOZ_CRASH("nsSHistory::GoForward");
 }
 
 NS_IMETHODIMP
 nsSHistory::Reload(uint32_t aReloadFlags)
 {
   uint32_t loadType;
   if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY &&
       aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE) {
@@ -1573,25 +1538,23 @@ nsSHistory::UpdateIndex()
 
   mRequestedIndex = -1;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHistory::Stop(uint32_t aStopFlags)
 {
-  // Not implemented
-  return NS_OK;
+  MOZ_CRASH("nsSHistory::Stop");
 }
 
 NS_IMETHODIMP
 nsSHistory::GetDocument(nsIDocument** aDocument)
 {
-  // Not implemented
-  return NS_OK;
+  MOZ_CRASH("nsSHistory::GetDocument");
 }
 
 NS_IMETHODIMP
 nsSHistory::GetCurrentURI(nsIURI** aResultURI)
 {
   NS_ENSURE_ARG_POINTER(aResultURI);
   nsresult rv;
 
@@ -1602,58 +1565,54 @@ nsSHistory::GetCurrentURI(nsIURI** aResu
   }
   rv = currentEntry->GetURI(aResultURI);
   return rv;
 }
 
 NS_IMETHODIMP
 nsSHistory::GetReferringURI(nsIURI** aURI)
 {
-  *aURI = nullptr;
-  // Not implemented
-  return NS_OK;
+  MOZ_CRASH("nsSHistory::GetReferringURI");
 }
 
 NS_IMETHODIMP
 nsSHistory::GetSessionHistoryXPCOM(nsISupports** aSessionHistory)
 {
-  *aSessionHistory = nullptr;
-  // Not implemented
-  return NS_OK;
+  MOZ_CRASH("nsSHistory::GetSessionHistoryXPCOM");
 }
 
 NS_IMETHODIMP
 nsSHistory::LoadURIWithOptions(const char16_t* aURI,
                                uint32_t aLoadFlags,
                                nsIURI* aReferringURI,
                                uint32_t aReferrerPolicy,
                                nsIInputStream* aPostStream,
                                nsIInputStream* aExtraHeaderStream,
                                nsIURI* aBaseURI,
                                nsIPrincipal* aTriggeringPrincipal)
 {
-  return NS_OK;
+  MOZ_CRASH("nsSHistory::LoadURIWithOptions");
 }
 
 NS_IMETHODIMP
 nsSHistory::SetOriginAttributesBeforeLoading(JS::HandleValue aOriginAttributes,
                                              JSContext* aCx)
 {
-  return NS_OK;
+  MOZ_CRASH("nsSHistory::SetOriginAttributesBeforeLoading");
 }
 
 NS_IMETHODIMP
 nsSHistory::LoadURI(const char16_t* aURI,
                     uint32_t aLoadFlags,
                     nsIURI* aReferringURI,
                     nsIInputStream* aPostStream,
                     nsIInputStream* aExtraHeaderStream,
                     nsIPrincipal* aTriggeringPrincipal)
 {
-  return NS_OK;
+  MOZ_CRASH("nsSHistory::LoadURI");
 }
 
 NS_IMETHODIMP
 nsSHistory::GotoIndex(int32_t aIndex)
 {
   return LoadEntry(aIndex, LOAD_HISTORY, HIST_CMD_GOTOINDEX);
 }