#include <stddef.h>
#include <string>
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "build/buildflag.h"
#include "build/chromeos_buildflags.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/find_bar/find_bar.h"
#include "chrome/browser/ui/find_bar/find_bar_controller.h"
#include "chrome/browser/ui/find_bar/find_bar_host_unittest_util.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/views/toolbar/pinned_toolbar_actions_container.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/find_result_waiter.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/find_in_page/find_notification_details.h"
#include "components/find_in_page/find_tab_helper.h"
#include "components/find_in_page/find_types.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "net/base/filename_util.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/views/layout/animating_layout_manager_test_util.h"
#if BUILDFLAG(IS_WIN)
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#endif
ASCIIToUTF16;
WideToUTF16;
NavigationController;
WebContents;
namespace {
const char kAnchorPage[] = …;
const char kAnchor[] = …;
const char kFramePage[] = …;
const char kFrameData[] = …;
const char kUserSelectPage[] = …;
const char kCrashPage[] = …;
const char kTooFewMatchesPage[] = …;
const char kLongTextareaPage[] = …;
const char kPrematureEnd[] = …;
const char kMoveIfOver[] = …;
const char kBitstackCrash[] = …;
const char kSelectChangesOrdinal[] = …;
const char kStartAfterSelection[] = …;
const char kSimple[] = …;
const char kLinkPage[] = …;
const bool kBack = …;
const bool kFwd = …;
const bool kIgnoreCase = …;
const bool kCaseSensitive = …;
const int kMoveIterations = …;
}
class FindInPageControllerTest : public InProcessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageFrames) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageFormsTextAreas) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, NoAudibleAlertOnFrameChange) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, NoAudibleAlertOnNavigation) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
AudibleAlertsWithPrepopulatedFind) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageSpecialURLs) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, StaleCountAfterNoResults) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
CommentsAndMetaDataNotSearchable) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, SpanSearchable) { … }
#if BUILDFLAG(IS_MAC) && !defined(NDEBUG)
#define MAYBE_LargePage …
#elif BUILDFLAG(IS_LINUX) && (!defined(NDEBUG) || defined(ADDRESS_SANITIZER))
#define MAYBE_LargePage …
#else
#define MAYBE_LargePage …
#endif
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_LargePage) { … }
#if (BUILDFLAG(IS_MAC) && !defined(NDEBUG)) || defined(ADDRESS_SANITIZER)
#define MAYBE_FindLongString …
#elif BUILDFLAG(IS_LINUX) && !defined(NDEBUG)
#define MAYBE_FindLongString …
#else
#define MAYBE_FindLongString …
#endif
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_FindLongString) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, BigString) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_MAC)
#define MAYBE_SingleOccurrence …
#else
#define MAYBE_SingleOccurrence …
#endif
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_SingleOccurrence) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindWholeFileContent) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageOrdinal) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
SelectChangesOrdinal_Issue20883) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
StartSearchAfterSelection) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageMultiFramesOrdinal) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPage_Issue5132) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, NavigateClearsOrdinal) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindUnselectableText) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindCrash_Issue1341577) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindCrash_Issue14491) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindRestarts_Issue1155639) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindRestarts_Issue70505) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPagePrematureEnd) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
HideFindBarOnNavigateAndReload) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindStayVisibleOnAnchorLoad) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
FindDisappearOnNewTabAndHistory) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindMovesWhenObscuring) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
FindNextInNewTabUsesPrepopulate) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, StayActive) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, RestartSearchFromF3) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_PreferPreviousSearch …
#else
#define MAYBE_PreferPreviousSearch …
#endif
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_PreferPreviousSearch) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulateSameTab) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulateInNewTab) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulatePreserveLast) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, NoIncognitoPrepopulate) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, ActivateLinkNavigatesPage) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FitWindow) { … }
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_FindMovesOnTabClose_Issue1343052 …
#else
#define MAYBE_FindMovesOnTabClose_Issue1343052 …
#endif
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
MAYBE_FindMovesOnTabClose_Issue1343052) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_GlobalPasteBoardClearMatches …
#else
#define MAYBE_GlobalPasteBoardClearMatches …
#endif
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
MAYBE_GlobalPasteBoardClearMatches) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, GlobalPasteboardIncognito) { … }
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, IncognitoFindNextSecret) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_IncognitoFindNextShared …
#else
#define MAYBE_IncognitoFindNextShared …
#endif
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
MAYBE_IncognitoFindNextShared) { … }