#include <utility>
#include <vector>
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/test/bind.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/history/history_tab_helper.h"
#include "chrome/browser/history/history_test_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/search_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/history/core/browser/history_service.h"
#include "components/history/core/browser/history_service_observer.h"
#include "components/history/core/common/pref_names.h"
#include "components/history/core/test/history_service_test_util.h"
#include "components/prefs/pref_service.h"
#include "components/search_engines/template_url_service.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/webui_config_map.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/fenced_frame_test_util.h"
#include "content/public/test/prerender_test_util.h"
#include "content/public/test/test_frame_navigation_observer.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "third_party/blink/public/common/features.h"
#include "ui/webui/untrusted_web_ui_browsertest_util.h"
#include "url/gurl.h"
BrowserThread;
_;
namespace {
class MockHistoryServiceObserver : public history::HistoryServiceObserver { … };
class VisitedLinkNavigationThrottleObserver
: public content::WebContentsObserver { … };
VisitedLinkNavigationThrottleObserver::VisitedLinkNavigationThrottleObserver(
content::WebContents* web_contents,
const GURL& url)
: … { … }
std::optional<uint64_t>
VisitedLinkNavigationThrottleObserver::GetVisitedLinkSalt() { … }
void VisitedLinkNavigationThrottleObserver::ReadyToCommitNavigation(
content::NavigationHandle* navigation_handle) { … }
}
class HistoryBrowserTest : public InProcessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryEnabled) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryDisabled) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryEnabledThenDisabled) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryDisabledThenEnabled) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, VerifyHistoryLength1) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, VerifyHistoryLength2) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, VerifyHistoryLength3) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest,
ConsiderRedirectAfterGestureAsUserInitiated) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest,
ConsiderSlowRedirectAsUserInitiated) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, DISABLED_HistorySearchXSS) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, PRE_HistoryPersists) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, HistoryPersists) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, InvalidURLNoHistory) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, InvalidSchemeNoHistory) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, NewTabNoHistory) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, IncognitoNoHistory) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, NavigateMultiTimes) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, MultiTabsWindowsHistory) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, DownloadNoHistory) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, HistoryRemovalRemovesTemplateURL) { … }
namespace {
void NavigateFrameToURL(content::RenderFrameHost* rfh, const GURL& url) { … }
}
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, Subframe) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, RedirectHistory) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, CrossSiteRedirectHistory) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, NavigateBringPageToTop) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, ReloadBringPageToTop) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, BackForwardBringPageToTop) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, PushStateSetsTitle) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, BeforeUnloadCommitDuringPending) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SubmitFormAddsTargetPage) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, OneHistoryTabPerWindow) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, ReplaceStateSamePageIsNotRecorded) { … }
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, VisitAnnotations) { … }
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_ObserversCallBothOnURLVisitedForLocalVisits …
#else
#define MAYBE_ObserversCallBothOnURLVisitedForLocalVisits …
#endif
IN_PROC_BROWSER_TEST_F(HistoryBrowserTest,
MAYBE_ObserversCallBothOnURLVisitedForLocalVisits) { … }
class HistoryMPArchBrowserTest : public HistoryBrowserTest { … };
class HistoryPrerenderBrowserTest : public HistoryMPArchBrowserTest { … };
IN_PROC_BROWSER_TEST_F(HistoryPrerenderBrowserTest,
PrerenderPageIsNotRecordedUnlessActivated) { … }
IN_PROC_BROWSER_TEST_F(HistoryPrerenderBrowserTest,
PrerenderPageIsRecordedIfActivated) { … }
IN_PROC_BROWSER_TEST_F(HistoryPrerenderBrowserTest,
PrerenderLastCommitedURLIsRecordedIfActivated) { … }
IN_PROC_BROWSER_TEST_F(HistoryPrerenderBrowserTest,
RedirectedPrerenderPageIsRecordedIfActivated) { … }
class HistoryFencedFrameBrowserTest : public HistoryMPArchBrowserTest { … };
IN_PROC_BROWSER_TEST_F(HistoryFencedFrameBrowserTest,
FencedFrameDoesNotAffectLoadingState) { … }
enum TestMode { … };
class HistoryVisitedLinksBrowserTest
: public HistoryBrowserTest,
public ::testing::WithParamInterface<TestMode> { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(HistoryVisitedLinksBrowserTest, GetSaltForSameOrigin) { … }
IN_PROC_BROWSER_TEST_P(HistoryVisitedLinksBrowserTest, AddSaltForCrossOrigin) { … }