Bug 1494713 - Pass the widget for the DocShell to `IHistory::VisitURI`. r=smaug
authorLina Cambridge <lina@yakshaving.ninja>
Fri, 16 Nov 2018 17:29:57 +0000
changeset 446796 3ab98d066db05f049c52d634bc5d6c3b66763810
parent 446795 1d50d21da50d91de52719decd7bf3e942a9ac89f
child 446797 155387956608096a66495a3da674e238efb49912
push id35052
push userapavel@mozilla.com
push dateSat, 17 Nov 2018 11:25:40 +0000
treeherdermozilla-central@efc1da42132b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1494713
milestone65.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 1494713 - Pass the widget for the DocShell to `IHistory::VisitURI`. r=smaug Differential Revision: https://phabricator.services.mozilla.com/D11287
docshell/base/IHistory.h
docshell/base/nsDocShell.cpp
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PBrowser.ipdl
dom/ipc/PContent.ipdl
dom/ipc/TabParent.cpp
dom/ipc/TabParent.h
mobile/android/components/build/nsAndroidHistory.cpp
toolkit/components/places/History.cpp
toolkit/components/places/tests/gtest/places_test_harness.h
toolkit/components/places/tests/gtest/test_IHistory.cpp
--- a/docshell/base/IHistory.h
+++ b/docshell/base/IHistory.h
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_IHistory_h_
 #define mozilla_IHistory_h_
 
 #include "nsISupports.h"
 
 class nsIURI;
+class nsIWidget;
 
 namespace mozilla {
 
 namespace dom {
 class Link;
 } // namespace dom
 
 // 0057c9d3-b98e-4933-bdc5-0275d06705e1
@@ -95,24 +96,27 @@ public:
     REDIRECT_SOURCE_PERMANENT = 1 << 5
   };
 
   /**
    * Adds a history visit for the URI.
    *
    * @pre aURI must not be null.
    *
+   * @param aWidget
+   *        The widget for the DocShell.
    * @param aURI
    *        The URI of the page being visited.
    * @param aLastVisitedURI
    *        The URI of the last visit in the chain.
    * @param aFlags
    *        The VisitFlags describing this visit.
    */
-  NS_IMETHOD VisitURI(nsIURI* aURI,
+  NS_IMETHOD VisitURI(nsIWidget* aWidget,
+                      nsIURI* aURI,
                       nsIURI* aLastVisitedURI,
                       uint32_t aFlags) = 0;
 
   /**
    * Set the title of the URI.
    *
    * @pre aURI must not be null.
    *
@@ -134,17 +138,18 @@ public:
 
 NS_DEFINE_STATIC_IID_ACCESSOR(IHistory, IHISTORY_IID)
 
 #define NS_DECL_IHISTORY \
   NS_IMETHOD RegisterVisitedCallback(nsIURI* aURI, \
                                      mozilla::dom::Link* aContent) override; \
   NS_IMETHOD UnregisterVisitedCallback(nsIURI* aURI, \
                                        mozilla::dom::Link* aContent) override; \
-  NS_IMETHOD VisitURI(nsIURI* aURI, \
+  NS_IMETHOD VisitURI(nsIWidget* aWidget, \
+                      nsIURI* aURI, \
                       nsIURI* aLastVisitedURI, \
                       uint32_t aFlags) override; \
   NS_IMETHOD SetURITitle(nsIURI* aURI, const nsAString& aTitle) override; \
   NS_IMETHOD NotifyVisited(nsIURI* aURI) override;
 
 } // namespace mozilla
 
 #endif // mozilla_IHistory_h_
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -28,16 +28,17 @@
 #include "mozilla/MediaFeatureChange.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ResultExtensions.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPrefs.h"
 #include "mozilla/StartupTimeline.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/Unused.h"
+#include "mozilla/WidgetUtils.h"
 
 #include "mozilla/dom/ClientChannelHelper.h"
 #include "mozilla/dom/ClientHandle.h"
 #include "mozilla/dom/ClientInfo.h"
 #include "mozilla/dom/ClientManager.h"
 #include "mozilla/dom/ClientSource.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/ContentFrameMessageManager.h"
@@ -12516,17 +12517,19 @@ nsDocShell::AddURIVisit(nsIURI* aURI,
     // 408 is special cased, since may actually indicate a temporary
     // connection problem.
     else if (aResponseStatus != 408 &&
              ((aResponseStatus >= 400 && aResponseStatus <= 501) ||
               aResponseStatus == 505)) {
       visitURIFlags |= IHistory::UNRECOVERABLE_ERROR;
     }
 
-    (void)history->VisitURI(aURI, aPreviousURI, visitURIFlags);
+    nsPIDOMWindowOuter* outer = GetWindow();
+    nsCOMPtr<nsIWidget> widget = widget::WidgetUtils::DOMWindowToWidget(outer);
+    (void)history->VisitURI(widget, aURI, aPreviousURI, visitURIFlags);
   }
 }
 
 //*****************************************************************************
 // nsDocShell: Helper Routines
 //*****************************************************************************
 
 NS_IMETHODIMP
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -3901,35 +3901,16 @@ ContentParent::RecvStartVisitedQuery(con
   }
   nsCOMPtr<IHistory> history = services::GetHistoryService();
   if (history) {
   history->RegisterVisitedCallback(newURI, nullptr);
   }
   return IPC_OK();
 }
 
-
-mozilla::ipc::IPCResult
-ContentParent::RecvVisitURI(const URIParams& uri,
-                            const OptionalURIParams& referrer,
-                            const uint32_t& flags)
-{
-  nsCOMPtr<nsIURI> ourURI = DeserializeURI(uri);
-  if (!ourURI) {
-    return IPC_FAIL_NO_REASON(this);
-  }
-  nsCOMPtr<nsIURI> ourReferrer = DeserializeURI(referrer);
-  nsCOMPtr<IHistory> history = services::GetHistoryService();
-  if (history) {
-    history->VisitURI(ourURI, ourReferrer, flags);
-  }
-  return IPC_OK();
-}
-
-
 mozilla::ipc::IPCResult
 ContentParent::RecvSetURITitle(const URIParams& uri,
                                const nsString& title)
 {
   nsCOMPtr<nsIURI> ourURI = DeserializeURI(uri);
   if (!ourURI) {
     return IPC_FAIL_NO_REASON(this);
   }
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -1037,20 +1037,16 @@ private:
   virtual mozilla::ipc::IPCResult RecvGetIconForExtension(const nsCString& aFileExt,
                                                           const uint32_t& aIconSize,
                                                           InfallibleTArray<uint8_t>* bits) override;
 
   virtual mozilla::ipc::IPCResult RecvGetShowPasswordSetting(bool* showPassword) override;
 
   virtual mozilla::ipc::IPCResult RecvStartVisitedQuery(const URIParams& uri) override;
 
-  virtual mozilla::ipc::IPCResult RecvVisitURI(const URIParams& uri,
-                                               const OptionalURIParams& referrer,
-                                               const uint32_t& flags) override;
-
   virtual mozilla::ipc::IPCResult RecvSetURITitle(const URIParams& uri,
                                                   const nsString& title) override;
 
   bool HasNotificationPermission(const IPC::Principal& aPrincipal);
 
   virtual mozilla::ipc::IPCResult RecvShowAlert(nsIAlertNotification* aAlert) override;
 
   virtual mozilla::ipc::IPCResult RecvCloseAlert(const nsString& aName,
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -885,16 +885,21 @@ child:
      */
     async SetWidgetNativeData(WindowsHandle aHandle);
 
     /**
      * Requests the content blocking log, which is sent back in response.
      */
     async GetContentBlockingLog() returns(nsString log, bool success);
 
+parent:
+    /** Records a history visit. */
+    async VisitURI(URIParams aURI, OptionalURIParams aLastVisitedURI,
+                   uint32_t aFlags);
+
 /*
  * FIXME: write protocol!
 
 state LIVE:
     send LoadURL goto LIVE;
 //etc.
     send Destroy goto DYING;
 
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -806,17 +806,16 @@ parent:
     // The async version of ClassifyLocal.
     async PURLClassifierLocal(URIParams uri, nsCString tables);
 
     async PLoginReputation(URIParams formURI);
 
     // Services remoting
 
     async StartVisitedQuery(URIParams uri);
-    async VisitURI(URIParams uri, OptionalURIParams referrer, uint32_t flags);
     async SetURITitle(URIParams uri, nsString title);
 
     async LoadURIExternal(URIParams uri, PBrowser windowContext);
     async ExtProtocolChannelConnectParent(uint32_t registrarId);
 
     // PrefService message
     sync GetGfxVars() returns (GfxVarUpdate[] vars);
 
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -94,16 +94,17 @@
 #include "gfxDrawable.h"
 #include "ImageOps.h"
 #include "UnitTransforms.h"
 #include <algorithm>
 #include "mozilla/NullPrincipal.h"
 #include "mozilla/WebBrowserPersistDocumentParent.h"
 #include "ProcessPriorityManager.h"
 #include "nsString.h"
+#include "IHistory.h"
 
 #ifdef XP_WIN
 #include "mozilla/plugins/PluginWidgetParent.h"
 #endif
 
 #if defined(XP_WIN) && defined(ACCESSIBILITY)
 #include "mozilla/a11y/AccessibleWrap.h"
 #include "mozilla/a11y/Compatibility.h"
@@ -3618,16 +3619,37 @@ TabParent::RecvShowCanvasPermissionPromp
   nsresult rv = os->NotifyObservers(browser, "canvas-permissions-prompt",
                                     NS_ConvertUTF8toUTF16(aFirstPartyURI).get());
   if (NS_FAILED(rv)) {
     return IPC_FAIL_NO_REASON(this);
   }
   return IPC_OK();
 }
 
+mozilla::ipc::IPCResult
+TabParent::RecvVisitURI(const URIParams& aURI,
+                        const OptionalURIParams& aLastVisitedURI,
+                        const uint32_t& aFlags)
+{
+  nsCOMPtr<nsIURI> ourURI = DeserializeURI(aURI);
+  if (!ourURI) {
+    return IPC_FAIL_NO_REASON(this);
+  }
+  nsCOMPtr<nsIURI> ourLastVisitedURI = DeserializeURI(aLastVisitedURI);
+  RefPtr<nsIWidget> widget = GetWidget();
+  if (NS_WARN_IF(!widget)) {
+    return IPC_OK();
+  }
+  nsCOMPtr<IHistory> history = services::GetHistoryService();
+  if (history) {
+    Unused << history->VisitURI(widget, ourURI, ourLastVisitedURI, aFlags);
+  }
+  return IPC_OK();
+}
+
 void
 TabParent::LiveResizeStarted()
 {
   SuppressDisplayport(true);
 }
 
 void
 TabParent::LiveResizeStopped()
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -623,16 +623,20 @@ protected:
 
   virtual mozilla::ipc::IPCResult RecvShowCanvasPermissionPrompt(const nsCString& aFirstPartyURI) override;
 
   mozilla::ipc::IPCResult
   RecvSetSystemFont(const nsCString& aFontName) override;
   mozilla::ipc::IPCResult
   RecvGetSystemFont(nsCString* aFontName) override;
 
+  virtual mozilla::ipc::IPCResult
+  RecvVisitURI(const URIParams& aURI, const OptionalURIParams& aLastVisitedURI,
+               const uint32_t& aFlags) override;
+
   ContentCacheInParent mContentCache;
 
   nsIntRect mRect;
   ScreenIntSize mDimensions;
   hal::ScreenOrientation mOrientation;
   float mDPI;
   int32_t mRounding;
   CSSToLayoutDeviceScale mDefaultScale;
--- a/mobile/android/components/build/nsAndroidHistory.cpp
+++ b/mobile/android/components/build/nsAndroidHistory.cpp
@@ -215,17 +215,20 @@ nsAndroidHistory::SaveVisitURI(nsIURI* a
   // Finally, notify that we've been visited.
   nsCOMPtr<nsIObserverService> obsService = mozilla::services::GetObserverService();
   if (obsService) {
     obsService->NotifyObservers(aURI, NS_LINK_VISITED_EVENT_TOPIC, nullptr);
   }
 }
 
 NS_IMETHODIMP
-nsAndroidHistory::VisitURI(nsIURI *aURI, nsIURI *aLastVisitedURI, uint32_t aFlags)
+nsAndroidHistory::VisitURI(nsIWidget* aWidget,
+                           nsIURI* aURI,
+                           nsIURI* aLastVisitedURI,
+                           uint32_t aFlags)
 {
   if (!aURI) {
     return NS_OK;
   }
 
   if (!(aFlags & VisitFlags::TOP_LEVEL)) {
     return NS_OK;
   }
--- a/toolkit/components/places/History.cpp
+++ b/toolkit/components/places/History.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Attributes.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/MemoryReporting.h"
 
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/ContentParent.h"
+#include "mozilla/dom/TabChild.h"
 #include "nsXULAppAPI.h"
 
 #include "History.h"
 #include "nsNavHistory.h"
 #include "nsNavBookmarks.h"
 #include "Helpers.h"
 #include "PlaceInfo.h"
 #include "VisitInfo.h"
@@ -22,16 +23,17 @@
 
 #include "mozilla/storage.h"
 #include "mozilla/dom/Link.h"
 #include "nsDocShellCID.h"
 #include "mozilla/Services.h"
 #include "nsThreadUtils.h"
 #include "nsNetUtil.h"
 #include "nsIFileURL.h"
+#include "nsIWidget.h"
 #include "nsIXPConnect.h"
 #include "nsIXULRuntime.h"
 #include "mozilla/Unused.h"
 #include "nsContentUtils.h" // for nsAutoScriptBlocker
 #include "nsJSUtils.h"
 #include "mozilla/ipc/URIUtils.h"
 #include "nsPrintfCString.h"
 #include "nsTHashtable.h"
@@ -2123,17 +2125,18 @@ History::IsRecentlyVisitedURI(nsIURI* aU
   // Check if the entry exists and is younger than RECENTLY_VISITED_URIS_MAX_AGE.
   return entry && (PR_Now() - entry->time) < RECENTLY_VISITED_URIS_MAX_AGE;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 //// IHistory
 
 NS_IMETHODIMP
-History::VisitURI(nsIURI* aURI,
+History::VisitURI(nsIWidget* aWidget,
+                  nsIURI* aURI,
                   nsIURI* aLastVisitedURI,
                   uint32_t aFlags)
 {
   MOZ_ASSERT(NS_IsMainThread());
   NS_ENSURE_ARG(aURI);
 
   if (mShuttingDown) {
     return NS_OK;
@@ -2141,20 +2144,20 @@ History::VisitURI(nsIURI* aURI,
 
   if (XRE_IsContentProcess()) {
     URIParams uri;
     SerializeURI(aURI, uri);
 
     OptionalURIParams lastVisitedURI;
     SerializeURI(aLastVisitedURI, lastVisitedURI);
 
-    mozilla::dom::ContentChild* cpc =
-      mozilla::dom::ContentChild::GetSingleton();
-    NS_ASSERTION(cpc, "Content Protocol is NULL!");
-    (void)cpc->SendVisitURI(uri, lastVisitedURI, aFlags);
+    NS_ENSURE_ARG(aWidget);
+    TabChild* tabChild = aWidget->GetOwningTabChild();
+    NS_ENSURE_TRUE(tabChild, NS_ERROR_FAILURE);
+    (void)tabChild->SendVisitURI(uri, lastVisitedURI, aFlags);
     return NS_OK;
   }
 
   nsNavHistory* navHistory = nsNavHistory::GetHistoryService();
   NS_ENSURE_TRUE(navHistory, NS_ERROR_OUT_OF_MEMORY);
 
   // Silently return if URI is something we shouldn't add to DB.
   bool canAdd;
--- a/toolkit/components/places/tests/gtest/places_test_harness.h
+++ b/toolkit/components/places/tests/gtest/places_test_harness.h
@@ -334,17 +334,18 @@ do_wait_async_updates() {
  * @param aURI
  *        The URI to add to the database.
  */
 void
 addURI(nsIURI* aURI)
 {
   nsCOMPtr<mozilla::IHistory> history = do_GetService(NS_IHISTORY_CONTRACTID);
   do_check_true(history);
-  nsresult rv = history->VisitURI(aURI, nullptr, mozilla::IHistory::TOP_LEVEL);
+  nsresult rv = history->VisitURI(nullptr, aURI, nullptr,
+                                  mozilla::IHistory::TOP_LEVEL);
   do_check_success(rv);
 
   do_wait_async_updates();
 }
 
 static const char TOPIC_PROFILE_CHANGE_QM[] = "profile-before-change-qm";
 static const char TOPIC_PLACES_CONNECTION_CLOSED[] = "places-connection-closed";
 
--- a/toolkit/components/places/tests/gtest/test_IHistory.cpp
+++ b/toolkit/components/places/tests/gtest/test_IHistory.cpp
@@ -422,17 +422,17 @@ test_observer_topic_dispatched()
 
 void
 test_visituri_inserts()
 {
   nsCOMPtr<IHistory> history = do_get_IHistory();
   nsCOMPtr<nsIURI> lastURI = new_test_uri();
   nsCOMPtr<nsIURI> visitedURI = new_test_uri();
 
-  history->VisitURI(visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL);
+  history->VisitURI(nullptr, visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL);
 
   RefPtr<VisitURIObserver> finisher = new VisitURIObserver();
   finisher->WaitForNotification();
 
   PlaceRecord place;
   do_get_place(visitedURI, place);
 
   do_check_true(place.id > 0);
@@ -446,21 +446,21 @@ test_visituri_inserts()
 void
 test_visituri_updates()
 {
   nsCOMPtr<IHistory> history = do_get_IHistory();
   nsCOMPtr<nsIURI> lastURI = new_test_uri();
   nsCOMPtr<nsIURI> visitedURI = new_test_uri();
   RefPtr<VisitURIObserver> finisher;
 
-  history->VisitURI(visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL);
+  history->VisitURI(nullptr, visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL);
   finisher = new VisitURIObserver();
   finisher->WaitForNotification();
 
-  history->VisitURI(visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL);
+  history->VisitURI(nullptr, visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL);
   finisher = new VisitURIObserver();
   finisher->WaitForNotification();
 
   PlaceRecord place;
   do_get_place(visitedURI, place);
 
   do_check_eq(place.visitCount, 2);
 
@@ -469,20 +469,20 @@ test_visituri_updates()
 
 void
 test_visituri_preserves_shown_and_typed()
 {
   nsCOMPtr<IHistory> history = do_get_IHistory();
   nsCOMPtr<nsIURI> lastURI = new_test_uri();
   nsCOMPtr<nsIURI> visitedURI = new_test_uri();
 
-  history->VisitURI(visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL);
+  history->VisitURI(nullptr, visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL);
   // this simulates the uri visit happening in a frame.  Normally frame
   // transitions would be hidden unless it was previously loaded top-level
-  history->VisitURI(visitedURI, lastURI, 0);
+  history->VisitURI(nullptr, visitedURI, lastURI, 0);
 
   RefPtr<VisitURIObserver> finisher = new VisitURIObserver(2);
   finisher->WaitForNotification();
 
   PlaceRecord place;
   do_get_place(visitedURI, place);
   do_check_false(place.hidden);
 
@@ -491,17 +491,17 @@ test_visituri_preserves_shown_and_typed(
 
 void
 test_visituri_creates_visit()
 {
   nsCOMPtr<IHistory> history = do_get_IHistory();
   nsCOMPtr<nsIURI> lastURI = new_test_uri();
   nsCOMPtr<nsIURI> visitedURI = new_test_uri();
 
-  history->VisitURI(visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL);
+  history->VisitURI(nullptr, visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL);
   RefPtr<VisitURIObserver> finisher = new VisitURIObserver();
   finisher->WaitForNotification();
 
   PlaceRecord place;
   VisitRecord visit;
   do_get_place(visitedURI, place);
   do_get_lastVisit(place.id, visit);
 
@@ -516,17 +516,17 @@ void
 test_visituri_transition_typed()
 {
   nsCOMPtr<nsINavHistoryService> navHistory = do_get_NavHistory();
   nsCOMPtr<IHistory> history = do_get_IHistory();
   nsCOMPtr<nsIURI> lastURI = new_test_uri();
   nsCOMPtr<nsIURI> visitedURI = new_test_uri();
 
   navHistory->MarkPageAsTyped(visitedURI);
-  history->VisitURI(visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL);
+  history->VisitURI(nullptr, visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL);
   RefPtr<VisitURIObserver> finisher = new VisitURIObserver();
   finisher->WaitForNotification();
 
   PlaceRecord place;
   VisitRecord visit;
   do_get_place(visitedURI, place);
   do_get_lastVisit(place.id, visit);
 
@@ -537,17 +537,17 @@ test_visituri_transition_typed()
 
 void
 test_visituri_transition_embed()
 {
   nsCOMPtr<IHistory> history = do_get_IHistory();
   nsCOMPtr<nsIURI> lastURI = new_test_uri();
   nsCOMPtr<nsIURI> visitedURI = new_test_uri();
 
-  history->VisitURI(visitedURI, lastURI, 0);
+  history->VisitURI(nullptr, visitedURI, lastURI, 0);
   RefPtr<VisitURIObserver> finisher = new VisitURIObserver();
   finisher->WaitForNotification();
 
   PlaceRecord place;
   VisitRecord visit;
   do_get_place(visitedURI, place);
   do_get_lastVisit(place.id, visit);
 
@@ -558,17 +558,17 @@ test_visituri_transition_embed()
 }
 
 void
 test_new_visit_adds_place_guid()
 {
   // First, add a visit and wait.  This will also add a place.
   nsCOMPtr<nsIURI> visitedURI = new_test_uri();
   nsCOMPtr<IHistory> history = do_get_IHistory();
-  nsresult rv = history->VisitURI(visitedURI, nullptr,
+  nsresult rv = history->VisitURI(nullptr, visitedURI, nullptr,
                                   mozilla::IHistory::TOP_LEVEL);
   do_check_success(rv);
   RefPtr<VisitURIObserver> finisher = new VisitURIObserver();
   finisher->WaitForNotification();
 
   // Check that we have a guid for our visit.
   PlaceRecord place;
   do_get_place(visitedURI, place);
@@ -590,17 +590,18 @@ test_two_null_links_same_uri()
   nsCOMPtr<nsIURI> testURI = new_test_uri();
 
   nsCOMPtr<IHistory> history = do_get_IHistory();
   nsresult rv = history->RegisterVisitedCallback(testURI, nullptr);
   do_check_success(rv);
   rv = history->RegisterVisitedCallback(testURI, nullptr);
   do_check_success(rv);
 
-  rv = history->VisitURI(testURI, nullptr, mozilla::IHistory::TOP_LEVEL);
+  rv = history->VisitURI(nullptr, testURI, nullptr,
+                         mozilla::IHistory::TOP_LEVEL);
   do_check_success(rv);
 
   RefPtr<VisitURIObserver> finisher = new VisitURIObserver();
   finisher->WaitForNotification();
 
   run_next_test();
 }